【问题标题】:VBv3.5 include directive throw's error when calling ProcessTemplate methodVBv3.5 在调用 ProcessTemplate 方法时包含指令 throw 的错误
【发布时间】:2009-07-15 14:58:08
【问题描述】:

我正在尝试通过 T4 生成一些代码,当我在模板中包含 指令时收到以下错误。

vbc:命令行 (0,0):错误 BC2006:编译转换:选项 'r' 需要 ':(file_list)

如果我使用 作为我的指令,它工作得很好。此外,如果我不尝试通过代码生成并仅保存 .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)

【问题讨论】:

    标签: vb.net .net-3.5 t4


    【解决方案1】:

    这适用于标准 T4 主机(在 Visual Studio 和 TextTransform 中)。根据错误,您的自定义主机似乎没有正确提供程序集引用列表。

    【讨论】:

    • 感谢您的回复。顺便说一句,我喜欢你的 T4 教程!只需将 .tt 文件保存在 Visual Studio 中,我就能让它正常工作(我假设这就是标准 T4 主机的意思?)。当我包含 VBv3.5 指令并在传入 CustomCmdLineHost 时执行 ProcessTemplate 方法时,它只会爆炸。如果我删除 VBv3.5 指令或将其切换到 C#v3.5 一切正常。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-09-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多