ILearnable .Net

November 29, 2010

Get C# 3.5 to work in a T4 template on VS2008

Filed under: Uncategorized — andreakn @ 08:15

In order to be able to use C# 3.5 in a .tt file on VS2008 you need to hack the devenv.exe.config file located at C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE, adding the following to the /configuration/runtime/assemblyBinding node

<!-- START T4 Hack -->
  <assemblyIdentity name="Microsoft.VisualStudio.TextTemplating" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
  <bindingRedirect oldVersion="" newVersion="" /> 
  <assemblyIdentity name="Microsoft.VisualStudio.TextTemplating.VSHost" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> 
  <bindingRedirect oldVersion="" newVersion="" /> 
<!-- END T4 Hack -->

You also need to explicitly declare that you want to use C# 3.5 in the top of the .tt file like this:

<#@ template debug="true" language="C#v3.5" #>

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: