Registering and Importing Namespaces

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

Use processing instructions to register namespaces, assemblies, and other properties for the installation of Windows SharePoint Services.

For Microsoft ASP.NET pages, use instructions such as the following at the beginning of the code, which register the Microsoft.SharePoint.WebControls, Microsoft.SharePoint.Utilities, Microsoft.SharePoint, and Microsoft.SharePoint.WebPartPages namespaces.

<%@ Register Tagprefix="SharePoint" 
   Namespace="Microsoft.SharePoint.WebControls" 
   Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, 
   PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" 
   Namespace="Microsoft.SharePoint.Utilities" 
   Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, 
   PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" 
   Namespace="Microsoft.SharePoint.WebPartPages" 
   Assembly="Microsoft.SharePoint, Version=11.0.0.0, Culture=neutral, 
   PublicKeyToken=71e9bce111e9429c" %>

You can obtain the PublicKeyToken value for the current Windows SharePoint Services deployment from the default.aspx file that is located in Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\SiteTemplates/sts, or from information provided for the Microsoft.SharePoint assembly at Local_Drive:\%Windir%\assembly in Windows Explorer.

In code-behind files or console applications, import namespaces in Microsoft Visual C# through the using directive, as follows.

using Microsoft.SharePoint;
using Microsoft.SharePoint.WebControls;
using Microsoft.SharePoint.WebPartPages;

In Microsoft Visual Basic, use the Imports statement to import namespaces, as follows.

Imports Microsoft.SharePoint
Imports Microsoft.SharePoint.WebControls
Imports Microsoft.SharePoint.WebPartPages

See Also

Concepts

How Do I... in Windows SharePoint Services

Working with List Objects and Collections

Other Resources

Sample Object Model Tasks