I am using the Microsoft.VisualStudio.TextTemplating.Engine
class from the VS 2008 SDK along with the objects from the Microsoft.Practices.RecipeFramework.VisualStudio.Library.Templates
namespace to automate the process of creating C# classes from T4 templates.
Here my code. It taken straight from the example on Oleg Sych's Blog...
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);
}
}
}
The Problem
I get a System.EntryPointNotFoundException
at the point where the template is processed and the output code file should be returned...
string output = engine.ProcessTemplate(template, host);
This exception suggests that I have a component version mismatch somewhere, and googling has revealed that this problem has been experienced by other, but with much older versions of the components I am using. My versions are...
Visual Studio SP1 9.0.30729.1
Microsoft.VisualStudio.TextTemplating 9.0.0.0
Microsoft.Practices.RecipeFramework.VisualStudio.Library 1.4.0.0
I have the latest versions of GAX, GAT and the VS2008 SDK (all downloaded and installed today).
Does anyone have any idea what is going on, or how I might investigate further?
I really want to avoid having to start using a tracer to follow the call stack if at all possible :(