【问题标题】:Microsoft.SharePoint.Client namespace-- Sharepoint namespace not recognizedMicrosoft.SharePoint.Client 命名空间--无法识别 Sharepoint 命名空间
【发布时间】:2011-04-15 22:30:24
【问题描述】:

我安装 SharePoint Foundation 2010 Client Object Model Redistributable 的目的是创建一个基本的控制台应用程序来检索站点名称,如 MSDN 上的 Using the SharePoint Foundation 2010 Managed Client Object Model 文章中所示。

在详细介绍开发人员如何创建控制台应用程序的部分中,本文创建了以下代码:

using System;
using Microsoft.SharePoint.Client;

class DisplayWebTitle
{
    static void Main()
    {
        ClientContext clientContext = new ClientContext("http://intranet.contoso.com");
        Web site = clientContext.Web;
        clientContext.Load(site);
        clientContext.ExecuteQuery();
        Console.WriteLine("Title: {0}", site.Title);
    }
}

我的问题是无法识别命名空间:Microsoft.Sharepoint.Client(sharepoint 下方的波浪线)。因此,无法识别 ClientContext 和 Web。我该怎么做才能让这个命名空间解决?

【问题讨论】:

标签: c# .net sharepoint


【解决方案1】:

转到项目的属性并将“Target Framework”修改为“.NET Framework 4”而不是“.NET Framework 4 Client Profile”

【讨论】:

    【解决方案2】:

    确保该程序集已添加到您的引用中。您应该可以从 12/14 配置单元中添加它。

    According to Microsoft 可以在这里找到:

    %ProgramFiles%\Common Files\Microsoft Shared\web 服务器扩展\14\ISAPI

    【讨论】:

    • 什么是 12/14 蜂巢?我有一个没有安装 sharepoint 的常规开发人员工作站。是否需要安装一些 sdk?
    • 您是否在工作站上安装了客户端对象模型?如果是这样,它应该在上面的路径中
    • 不,我没有 ISAPI 目录。我安装了 2010 可再发行组件,但我没有这个目录。我确实有一个 14\BIN,但不是你建议的
    • 在你的 14 文件夹中四处寻找(从 BIN 目录开始),看看你是否能找到 Microsoft.SharePoint.Client.dll。如果你的机器上有它,我很确定它会在那里。找到后将其添加到项目中的引用中。
    猜你喜欢
    • 2014-01-21
    • 2019-12-19
    • 2012-05-07
    • 2018-03-21
    • 1970-01-01
    • 2011-10-05
    • 2011-10-19
    • 2015-02-17
    • 2018-02-20
    相关资源
    最近更新 更多