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 --> <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> <!-- 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" #>
Advertisement
