Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Important This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here.

How to: Reference Assemblies in Text Templates 

Visual Studio 2005

You can add an assembly directive to text templates and use that directive 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

  1. In Solution Explorer, right-click the text template file that you want to edit, and then click Open.

    The file opens in the editor.

  2. Add the following directive to the template:

    <#@ assembly name = "C:\Assemblies\Assembly.dll" #>
    
    NoteNote

      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:

  3. To access the assembly, add code that is similar to the following:

    <#=Class1.DoSomething();#>
    

    <#=Class1.DoSomething()#>
    
    NoteNote

    In this example, Class1 is a type that is defined in the assembly Assembly.dll.

    NoteNote

    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

Community Additions

ADD
Show:
© 2015 Microsoft