名前空間を登録およびインポートする

最終更新日: 2010年3月8日

適用対象: SharePoint Foundation 2010

Microsoft SharePoint Foundation の名前空間、アセンブリ、およびその他のプロパティを登録するには、処理命令を使用します。

Microsoft ASP.NET のページでは、コードの先頭で次のような命令を使用します。これらの命令によって、Microsoft.SharePoint.WebControlsMicrosoft.SharePoint.UtilitiesMicrosoft.SharePoint、および Microsoft.SharePoint.WebPartPages 名前空間が登録されます。

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

現在の SharePoint Foundation 展開の PublicKeyToken 値を default.aspx ファイルから取得できます。このファイルは Local_Drive:\Program Files\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\SiteTemplates\sts にあります。または、Local_Drive:\%Windir%\assembly にある Microsoft.SharePoint アセンブリに対して提供された情報から取得できます。

分離コード ファイルまたはコンソール アプリケーションで、次のように で using ディレクティブを使用して名前空間をインポートします。

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

Microsoft Visual Basic で、次のように Imports ステートメントを使用して名前空間をインポートします。

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

関連項目

概念

サイト、Web アプリケーション、およびその他の主要オブジェクトへの参照を取得する

リストのオブジェクトとコレクションを操作する

その他の技術情報

基本的なオブジェクト モデルのタスク