共用方式為


TextTransformation.Error 方法

建立新錯誤,以儲存在文字範本轉換程序期間發生的錯誤資訊。

命名空間:  Microsoft.VisualStudio.TextTemplating
組件:  Microsoft.VisualStudio.TextTemplating.11.0 (在 Microsoft.VisualStudio.TextTemplating.11.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