TextTransformation.Error 方法

创建一个新错误来存储文本模板转换进程期间发生的错误的相关信息。

命名空间:  Microsoft.VisualStudio.TextTemplating
程序集:  Microsoft.VisualStudio.TextTemplating.10.0(在 Microsoft.VisualStudio.TextTemplating.10.0.dll 中)

语法

声明
Public Sub Error ( _
    message As String _
)
public void Error(
    string message
)
public:
void Error(
    String^ message
)
member Error : 
        message:string -> unit 
public function Error(
    message : String
)

参数

备注

向文本模板转换进程的 Errors 的集合添加错误。 默认情况下,将错误的行号设置为 -1,将错误的列号设置为 -1。

示例

下面的代码示例演示从文本模板调用 Error 方法。 将此代码粘贴到任何文本模板文件中并运行文本模板转换以查看结果。 该错误将出现在错误列表中。

<#
    string firstName = null;

    if(string.IsNullOrEmpty(firstName))
    {
        //raise an error, this will appear in the error list
        Error("I have no name.");
    }
#> 
<#
    Dim firstName as string = ""

    If string.IsNullOrEmpty(firstName) Then

        'raise an error, this will appear in the error list
        Me.Error("I have no name.")
    End If
#>

.NET Framework 安全性

请参见

参考

TextTransformation 类

Microsoft.VisualStudio.TextTemplating 命名空间

Errors

其他资源

How to: Generate Errors and Warnings from Text Templates