You can add an assemblydirective to text templates. This enables you to specify assemblies that you want to use in those text templates. You can add your own assembly to a text template and use types and members from within it. For more information, see Directive Syntax (Domain-Specific Languages).
To add an assembly to a text template
In Solution Explorer, right-click the text template file that you want to edit, and then click Open.
The file opens in the editor.
Add the following directive to the template:
<#@ assembly name = "C:\Assemblies\Assembly.dll" #>注意
You can either specify a strong name for assemblies in the global assembly cache or you can specify a fully qualified path to the assembly's file name.
Here is an example of how to specify a strong name:
To access the assembly, add code that is similar to the following:
<#=Class1.DoSomething();#><#=Class1.DoSomething()#>注意
In this example, Class1 is a type that is defined in the assembly Assembly.dll.
注意
To debug text templates, you must set the debug parameter of the template directive. For more information, see How to: Debug Text Templates.
Security
For more information, see Security of Text Templates.
See Also
Concepts
Using Built-in Directives in Text Templates