This documentation is archived and is not being maintained.
ITextTemplatingEngineHost::LogErrors Method
Visual Studio 2012
Receives a collection of errors and warnings from the transformation engine.
Assembly: Microsoft.VisualStudio.TextTemplating.Interfaces.10.0 (in Microsoft.VisualStudio.TextTemplating.Interfaces.10.0.dll)
You can call this method from a text template. You must set hostspecific="true".
<#@ template hostspecific="true" language="C#" #> <#@ output extension=".txt" #> <#@ import namespace="System.CodeDom.Compiler" #> <# string message = "test message"; this.Host.LogErrors(new CompilerErrorCollection() { new CompilerError( this.Host.TemplateFile, // Identify the source of the error. 0, 0, "0", // Line, column, error ID. message) }); // Message displayed in error window. #>
The following code example shows a possible implementation for a custom host. In this example, the errors are stored in a property. The program that instantiates this custom host will access the property and write the errors to the Console. This code example is part of a larger example. For the complete example, see Walkthrough: Creating a Custom Text Template Host.
The following code example shows another possible implementation for a custom host. In this example, the errors are written to the Console immediately.
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.
Show: