7

ビジュアルスタジオテンプレートウィザードのGUIが表示されるのに問題があります。 http://msdn.microsoft.com/en-us/library/ms185301.aspxVS2012テンプレートウィザード - GUIが表示されない

ここに私がやったことだ:私はこれらの手順に従っ

1)以下のファイルをC#クラスライブラリ(.dll)を生成:

UserInputForm.cs

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Data; 
using System.Drawing; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows.Forms; 

namespace myprojectvstemplate 
{ 
    public partial class UserInputForm : Form 
    { 
     private string customMessage; 

     public UserInputForm() 
     { 

      InitializeComponent(); 
      MessageBox.Show("here, calling ui"); 
     } 

     public string get_CustomMessage() 
     { 
      return customMessage; 
     } 

     private void button1_Click(object sender, EventArgs e) 
     { 
      customMessage = textBox1.Text; 

      this.Dispose(); 
     } 
    } 
} 

2 )編集ボックスとコード付きのコンボボックス付きのユーザー入力フォームを追加しました。UserInputForm.cs

using System; 
using System.Collections.Generic; 
using Microsoft.VisualStudio.TemplateWizard; 
using System.Windows.Forms; 
using EnvDTE; 

namespace myprojectvstemplate 
{ 
    public class IWizardImplementation : IWizard 
    { 
     private UserInputForm inputForm; 
     private string customMessage; 

     // This method is called before opening any item that 
     // has the OpenInEditor attribute. 
     public void BeforeOpeningFile(ProjectItem projectItem) 
     { 

     } 

     public void ProjectFinishedGenerating(Project project) 
     { 

     } 

     // This method is only called for item templates, 
     // not for project templates. 
     public void ProjectItemFinishedGenerating(ProjectItem 
      projectItem) 
     { 

     } 

     // This method is called after the project is created. 
     public void RunFinished() 
     { 

     } 

     public void RunStarted(object automationObject, 
      Dictionary<string, string> replacementsDictionary, 
      WizardRunKind runKind, object[] customParams) 
     { 


      try 
      { 
       // Display a form to the user. The form collects 
       // input for the custom message. 
       inputForm = new UserInputForm(); 
       inputForm.ShowDialog(); 

       customMessage = inputForm.get_CustomMessage(); 

       // Add custom parameters. 
       replacementsDictionary.Add("$custommessage$", 
        customMessage); 
      } 
      catch (Exception ex) 
      { 
       MessageBox.Show(ex.ToString()); 
      } 
     } 

     // This method is only called for item templates, 
     // not for project templates. 
     public bool ShouldAddProjectItem(string filePath) 
     { 

      return true; 
     } 
    } 
} 

3)ます。gacutilでそれを登録し、パブリック/プライベート強い鍵を生成し、プロパティページ

4)DLL をリリース、生成された)に「署名」タブからアセンブリを登録/私はmydllname。 DLL、ただ一つのファイルでC++のコンソールプロジェクトテンプレートを作成したエラーなし ):

#include <iostream> 
using namespace std; 


int main(int argc, char** argv) 
{ 

    cout << "Hi hello world:" << "$custommessage$"; 

    return 0; 
} 

7)「に自動的に対にインポートする」にチェックボックスでテンプレートプロジェクト(ない項目)としてエクスポート。私は、UIがまったく表示されていない新しいテンプレートプロジェクトを作成しようとすると、残念ながら

<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project"> 
    <TemplateData> 
    <Name>myproject_project</Name> 
    <Description>&lt;No description available&gt;</Description> 
    <ProjectType>VC</ProjectType> 
    <ProjectSubType> 
    </ProjectSubType> 
    <SortOrder>1000</SortOrder> 
    <CreateNewFolder>true</CreateNewFolder> 
    <DefaultName>myproject_project</DefaultName> 
    <ProvideDefaultName>true</ProvideDefaultName> 
    <LocationField>Enabled</LocationField> 
    <EnableLocationBrowseButton>true</EnableLocationBrowseButton> 
    <Icon>__TemplateIcon.ico</Icon> 
    </TemplateData> 
    <TemplateContent> 
    <Project TargetFileName="myproject_project.vcxproj" File="myproject_project.vcxproj" ReplaceParameters="true"> 
     <ProjectItem ReplaceParameters="false" TargetFileName="$projectname$.vcxproj.filters">myproject_project.vcxproj.filters</ProjectItem> 
     <ProjectItem ReplaceParameters="true" TargetFileName="myproject_project.cpp">myproject_project.cpp</ProjectItem> 
     <ProjectItem ReplaceParameters="false" TargetFileName="ReadMe.txt">ReadMe.txt</ProjectItem> 
    </Project> 
    </TemplateContent> 
    <WizardExtension> 
    <Assembly>myprojectvstemplate, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=a0a3d031ed112d61</Assembly> 
    <FullClassName>myprojectvstemplate.IWizardImplementation</FullClassName> 
    </WizardExtension> 
</VSTemplate> 

:ファスナー内部でこのような.vstemplateファイルをファイルに変更。プロジェクトは開かれたばかりで、$ custommessage $パラメータの代用はありません。

ウィザードのGUIを表示できないのはなぜですか?

さらに、アセンブリがロードされていない理由をデバッグする方法はありますか?

答えて

1

は、私は同じチュートリアル以下、OPと同じ問題を抱えていました。私が見つけた

ソリューションは、このでした:テンプレートセクションを変更

ステップ2フォルダにzipファイルを解凍し、zipファイルを削除します。次に、vstemplateを変更します。

最後に、VSの新しいインスタンスでウィザードを試してください。

これが適切な解決策であるかどうかはわかりませんが、これが私にとってうまくいきました。

+0

私は多くのトリッキーと機械をやらなければならなかったが、ありがとうParesh、ちょうど私にヒントを与えたが、私はついにそれを働かせた。 –

+0

お手伝いします:) – Paresh138

1

おそらく、ウィザードの実装によるアセンブリが見つかりません。

WizardExtensionセクションでは、アセンブリとクラス名を正確に記述する必要があります。

もちろん、このアセンブリは拡張ディレクトリにあるか、GACに登録する必要があります。

<WizardExtension> 
    <Assembly>myprojectvstemplate, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=a0a3d031ed112d61</Assembly> 
    <FullClassName>myprojectvstemplate.IWizardImplementation</FullClassName> 
</WizardExtension> 

おかげで、セルジュ

+0

上記のようにgacutil.exeで登録したところ、「アセンブリは正常に登録されました」というエラーは表示されませんでした。ウィザードエクステンションに関して、私は文化について100%確信していません(アセンブリには "none"と書かれています)が、ニュートラルは同じことだと思います。トークンは最新であり、アセンブリ名はメイン名前空間名と同じであり、fullclassnameはアセンブリ名です。 IWizardImplementation(私のUIクラス) –

+0

場合によっては例外をキャッチすることができます: 1)VS2012の最初のインスタンスで新しいプロジェクトダイアログを開きます。 2)VS2012の2番目のインスタンスを開きます 3)VS2012の2番目のインスタンスからデバッガを接続します 4)VS2012の2番目のインスタンスで例外を有効にする 5)VS2012の最初のインスタンスで新しいプロジェクトを作成します いくつかの例外がある場合は、VS2012の2番目のインスタンスに表示されます – TSV

+0

Triedこれは例外ですが、この例外はありません。 "値が期待した範囲内に収まらない"。 残念ながら、私はそれがどの範囲/値を参照しているのか分かりません。テンプレートプロジェクトを使用してvs2012用の簡単なウィザードを作成し、それを私に送っていただければ、私が間違っている場所を確認できるので、感謝しています。これは上記の手順に沿って5分の作業でなければならないと私は間違って取得していないことを確認してください –

関連する問題