2009-07-15 19 views
0

我試圖通過T4生成一些代碼,並且在我包含<#@ template language =「VBv3.5」#>指令時收到以下錯誤模板。VBv3.5在調用ProcessTemplate方法時包含指令throw的錯誤

VBC:命令行(0,0):錯誤BC2006:Compinling轉型:選項 'R' 需要「:(file_list中)

如果我使用<#@模板語言= 「C#V3.5」 #>作爲我的指令,它工作得很好。另外,如果我不試圖通過代碼生成並保存.tt文件,它可以很好地適用於VBv3.5指令。

這是我的t4模板。

<#@ output extension="txt" #> 
<#@ assembly name="Microsoft.SqlServer.ConnectionInfo" #> 
<#@ assembly name="Microsoft.SqlServer.Smo" #> 
<#@ assembly name="System.Configuration" #> 
<#@ assembly name="Microsoft.VisualBasic" #> 
hello world 

這裏是我的.NET代碼

Dim host As CustomCmdLineHost = New CustomCmdLineHost() 
    Dim engine As Engine = New Engine() 

    host.TemplateFileValue = sTemplateFile 

    'Read the text template. 
    Dim input As String = File.ReadAllText(sTemplateFile) 

    'Transform the text template. 
    Dim output As String = engine.ProcessTemplate(input, host) 

回答

0

這可以與標準的T4主機(在Visual Studio和TextTransform)。根據錯誤,看起來您的自定義主機不能正確提供程序集引用列表。

+0

感謝您的回覆。順便提一下,我喜歡你的T4教程! 在Visual Studio中保存.tt文件時,我能夠很好地工作(我假設您是指標準T4主機的含義?)。當我包含VBv3.5指令並在傳遞CustomCmdLineHost時執行ProcessTemplate方法時,它只是炸彈。如果我刪除VBv3.5指令或將其切換到C#v3.5,一切正常。 – vonfeldj 2009-07-16 20:15:44