找不到SPSite命名空间 [英] cannot find the SPSite name space

查看:152
本文介绍了找不到SPSite命名空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到SPSite

到目前为止,我已经导入了这些

I have imported these so far:

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/");
        }
    }
}

SPSite和下面仍然有红线.

And SPSite still has red line under it.

推荐答案

由于 SPSite类服务器边对象模型API的一部分:

This error occurs since SPSite class is a part of Server Side Object Model API:

服务器端对象模型 API只能在安装SharePoint Server/Foundation的计算机上使用.

Server Side Object Model API could be utilized only on machine where SharePoint Server/Foundation is installed.

因为您使用的是客户端对象模型API (项目Microsoft.SharePoint.Client.dll中的引用程序集是

Since you are using Client Object Model API (referenced assembly in your project Microsoft.SharePoint.Client.dll is a part of SharePoint Server 2013 Client Components SDK) i would recommend to utilize this API.

因此,这行:

SPSite oSPSite = new SPSite("http://spdevserver:1002/");  //SSOM

可以替换为:

using(var ctx = new ClientContext("http://spdevserver:1002/"))
{
    var site = ctx.Site;
    //...
}

参考文献

  • 在SharePoint 2013中选择正确的API设置
  • References

    • Choose the right API set in SharePoint 2013
    • 这篇关于找不到SPSite命名空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆