VS 2008 SDK でテキスト テンプレート エンジンを使用すると、「エントリ ポイントが見つかりません」エラーが発生する

StackOverflow https://stackoverflow.com/questions/690585

  •  22-08-2019
  •  | 
  •  

質問

私が使用しているのは、 Microsoft.VisualStudio.TextTemplating.Engine VS 2008 SDK のクラスと、 Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates 名前空間を使用して、T4 テンプレートから C# クラスを作成するプロセスを自動化します。

ここに私のコードがあります。例からそのまま引用しました オレグ・シチさん ブログ...

using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates;
using Microsoft.VisualStudio.TextTemplating; 

namespace PropertyDirectivePot
{
  class Program
  {
    static void Main(string[] args)
    {
      // Prepare template parameters
      var arguments = new Dictionary<string, PropertyData>();
      arguments.Add(“MyProperty”,
        new PropertyData(Color.AntiqueWhite, typeof(Color))); 

      // Initialize GAX template host
      string currentDirectory = Directory.GetCurrentDirectory();
      TemplateHost host = new TemplateHost(currentDirectory, arguments);
      host.TemplateFile = Path.Combine(currentDirectory, “PropertyTest.tt”); 

      // Transform template
      string template = File.ReadAllText(host.TemplateFile);
      ITextTemplatingEngine engine = new Engine();
      string output = engine.ProcessTemplate(template, host); 

      // Save output
      string outputFile = Path.ChangeExtension(host.TemplateFile, “.txt”);
      File.WriteAllText(outputFile, output);
    }
  }
}

問題

を取得します System.EntryPointNotFoundException テンプレートが処理され、出力コード ファイルが返される必要がある時点で...

string output = engine.ProcessTemplate(template, host);

この例外は、コンポーネントのバージョンがどこかで一致していないことを示唆しています。 グーグルする この問題は他の人でも発生していることが明らかになりましたが、私が使用しているはるかに古いバージョンのコンポーネントでも発生しています。私のバージョンは...

ビジュアルスタジオ SP1 9.0.30729.1
Microsoft.VisualStudio.TextTemplate 9.0.0.0
Microsoft.Practices.RecipeFramework.VisualStudio.Library 1.4.0.0

私は GAX、GAT、VS2008 SDK の最新バージョンを持っています (すべて今日ダウンロードしてインストールしました)。

何が起こっているのか、またはさらに調査するにはどうすればよいかわかる人はいますか?

可能な限り、コールスタックを追跡するためにトレーサーの使用を開始する必要は本当に避けたいです:(

役に立ちましたか?

解決

答えが見つかりました...

間違ったバージョンを参照していました Microsoft.VisualStudio.TextTemplating 組み立て。

私のマシンには 2 つのバージョンがインストールされていました...

  • 8.1.0.0
  • 9.0.0.0

の特定のバージョン Microsoft.Practices.RecipeFramework.VisualStudio.Library 私が使用していたものは、2 つのバージョンのうち早い方のバージョンが必要でした。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top