Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual Studio SDK
 How to: Import Namespaces in Text T...

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Domain-Specific Language Tools 
How to: Import Namespaces in Text Templates 

You can add an import directive to text templates and use that directive to specify the namespaces that you want to use in those text templates. For more information, see Directive Syntax (Domain-Specific Languages).

You can add a namespace to a text template to avoid having to use fully qualified names in the code in your text template.

To import a namespace

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

    The template opens in the editor.

  2. Specify a namespace using the import directive, as shown in the following example:

    <#@ import namespace = "System.Collections.Generic" #>

Example

The following example demonstrates how to use the import directive.

C#
<#@ import namespace = "System.Collections.Generic" #>
<#
    List<string> names=new List<string>();
#>
Visual Basic
<#@ import namespace = "System.Collections.Generic" #>
<#
    Dim names As List(Of String) = New List(Of String)
#>

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

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker