Export (0) Print
Expand All

Registering and Importing Namespaces

Windows SharePoint Services 3

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" 
   Assembly="Microsoft.SharePoint, Version=, Culture=neutral, 
   PublicKeyToken=71e9bce111e9429c" %>
<%@ Register Tagprefix="Utilities" 
   Assembly="Microsoft.SharePoint, Version=, Culture=neutral, 
   PublicKeyToken=71e9bce111e9429c" %>
<%@ Import Namespace="Microsoft.SharePoint" %>
<%@ Register Tagprefix="WebPartPages" 
   Assembly="Microsoft.SharePoint, Version=, 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
© 2014 Microsoft