我需要指定我的 T4 以使用 C# 4.0 来呈现我的 tt 文件吗?我尝试使用
<#@ template language="C#v4.0" debug="true" #>
但是当我使用动态变量时,就像这样
dynamic x=10;
Write(x.ToString());
我收到这些错误
Error 2 Compiling transformation: Predefined type 'Microsoft.CSharp.RuntimeBinder.CSharpSetMemberBinder' is not defined or imported e:\projects\DynamicModel\DynamicModel\ModelGenerator.tt 1 1
Error 3 Compiling transformation: Missing compiler required member 'Microsoft.CSharp.RuntimeBinder.CSharpInvokeMemberBinder..ctor' e:\projects\DynamicModel\DynamicModel\ModelGenerator.tt 1 1
Error 4 Compiling transformation: Missing compiler required member 'System.Runtime.CompilerServices.CallSite.Create' e:\projects\DynamicModel\DynamicModel\ModelGenerator.tt 1 1
Error 5 Compiling transformation: One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll? e:\Projects\DynamicModel\DynamicModel\ModelGenerator.tt 7 8
Error 6 A namespace cannot directly contain members such as fields or methods e:\projects\DynamicModel\DynamicModel\ModelGenerator.cs 1 1 DynamicModel
另外,请注意我使用的是 TextTemplatingFileGenerator 而不是预处理器模板