Visual Studio Development Bookmark and Share   
 index > Visual Studio Guidance Automation Toolkit > Problem Unit Testing T4 Templates in VS2008
 

Problem Unit Testing T4 Templates in VS2008

Hi,

I am using unit tests to test my templates, using the Engine and the TemplateHost class.

string rootDir = Directory.GetCurrentDirectory();
IDictionary<string, PropertyData> arguments =
new Dictionary<string, PropertyData>();

arguments["myarg"] = new PropertyData(1, typeof(long));
TemplateHost host = new TemplateHost(rootDir, arguments);

host.TemplateFile = "myfile.t4";

Engine engine = new Engine();
engine.ProcessTemplate(File.ReadAllText(host.TemplateFile), host);

The instruction engine.ProcessTemplate just stop the test with the error

Test method mymethod threw exception: System.EntryPointNotFoundException: Entry point was not found..


Microsoft.VisualStudio.TextTemplating.ITextTemplatingEngineHost.get_TemplateFile()
Microsoft.VisualStudio.TextTemplating.Engine.ProcessTemplate(String content, ITextTemplatingEngineHost host)
mymethod() in myfile.cs: line 78

I am using VS2008, GAX Feb 2008 and GAT for VS2008.

Any idea?

Thanks in advance





BFC  Thursday, September 11, 2008 11:45 PM
Hi,

Actually GAX is still using a text template 8.1 assembly version, so what you can do is fix your reference (which actually should be 9.0) and use the 8.1 version or you can also add the following assemblies redirects in your devenv.exe.config:

<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TextTemplating" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TextTemplating.VSHost" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>


hth.
jose

Jose Escrich - weblogs.asp.net/jescrich
  • Proposed As Answer byJose Escrich Wednesday, September 17, 2008 10:11 PM
  • Marked As Answer byBFC Thursday, September 18, 2008 6:06 AM
  •  
Jose Escrich  Wednesday, September 17, 2008 9:51 PM
Hi,

Actually GAX is still using a text template 8.1 assembly version, so what you can do is fix your reference (which actually should be 9.0) and use the 8.1 version or you can also add the following assemblies redirects in your devenv.exe.config:

<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TextTemplating" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.TextTemplating.VSHost" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>


hth.
jose

Jose Escrich - weblogs.asp.net/jescrich
  • Proposed As Answer byJose Escrich Wednesday, September 17, 2008 10:11 PM
  • Marked As Answer byBFC Thursday, September 18, 2008 6:06 AM
  •  
Jose Escrich  Wednesday, September 17, 2008 9:51 PM

You can use google to search for other answers

Custom Search

More Threads

• Microsoft.Practices.RecipeFramework.VisualStudio
• Register more then one Solution template
• Code samples anywhere ?
• Creating a Recipe for updating a config file
• ProjectItem TargetFileName in App_Code folder
• Schema Discovery component
• How do I uninstall GAX manually from a Vista64bit os
• Some items in HoL don't match GAT
• Help me decide: how to generate my Data Access Layer ( please :)
• XML Literal in .tt template