我用的 Microsoft.VisualStudio.TextTemplating.Engine 类从VS2008SDK沿用的对象 Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates 名字空间的过程自动化的创造C#类T4的模板。

在这里,我的代码。它采取直接从例如在 奥列格Sych的 博客...

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);

这种例外的建议,我有一个组件版本的不匹配的地方, 谷歌上搜索 已经显示,这个问题已经经历的其他,但有更旧的版本的组成我的使用。我的版本是...

Visual Studio SP1 9.0.30729.1
Microsoft。Visual studio.来说 9.0.0.0
Microsoft。实践。RecipeFramework.Visual studio.图书馆 1.4.0.0

我有最新版本的GAX,GAT和VS2008SDK(所有下载,安装了今天)。

没有任何人有任何想法什么,或者我怎么可能进一步的调查?

我真的想要避免开始使用一种示踪遵循的呼叠,如果在所有可能的:(

有帮助吗?

解决方案

找到答案...

我refernecing错误的版本 Microsoft.VisualStudio.TextTemplating 大会。

我有两个版本的安装在我的机器...

  • 8.1.0.0
  • 9.0.0.0

特别的版本 Microsoft.Practices.RecipeFramework.VisualStudio.Library 我是使用所需的较早的两个版本。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top