t4模板linq问题

时间:2012-06-10 11:55:35

标签: linq templates t4

如何在T4模板中使用Linq

这是我的软件环境信息 vs2012 .net 4.0版

这是t4模板:

<#@ templatedebug="true" hostSpecific="true" #> 
<#@ output extension=".cs" #> 
<#@ Assembly Name="System.Core.dll" #> 
<#@ import namespace="System" #> 
<#@ import namespace="System.Linq" #> 

当我调用engine.ProcessTemplate(inputTemplate,host)时,它返回的内容 ErrorGeneratingOutput。那是为什么?

2 个答案:

答案 0 :(得分:3)

老问题我知道,但我刚刚发现了同样的事情。

当您引用System.Core时,请不要包含.dll

<#@ assembly name="System.Core" #>

答案 1 :(得分:0)

您需要查看visual studio错误窗口中的错误以查看更多信息。

您也可以右键单击.tt文件并说出调试模板。