我无法找到名称空间SPSite
到目前为止我已经导入了这些:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using Microsoft.SharePoint;
using System.Collections;
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint;
using System.Data.SqlClient;
using SP = Microsoft.SharePoint.Client;
using System.Data;
namespace GrandPermission
{
class Program
{
static void Main(string[] args)
{
SPSite oSPSite = new SPSite("http://spdevserver:1002/");
}
}
}
And SPSite
still has red line under it.
出现此错误是因为SPS站点类 https://technet.microsoft.com/en-us/library/microsoft.sharepoint.spsite.aspx是一部分Server侧面对象模型 API:
服务器端对象模型可以利用APIonly在安装了 SharePoint Server/Foundation 的计算机上。
既然你正在使用客户端对象模型API(在您的项目中引用了程序集Microsoft.SharePoint.Client.dll
是一部分SharePoint Server 2013 客户端组件 SDK http://www.microsoft.com/en-us/download/details.aspx?id=35585)我建议使用这个 API。
所以,这一行:
SPSite oSPSite = new SPSite("http://spdevserver:1002/"); //SSOM
可以替换为:
using(var ctx = new ClientContext("http://spdevserver:1002/"))
{
var site = ctx.Site;
//...
}
参考
- 在 SharePoint 2013 中选择正确的 API 集 https://msdn.microsoft.com/en-us/library/office/jj164060.aspx
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)