简体   繁体   中英

Microsoft.SharePoint.Client namespace— Sharepoint namespace not recognized

I installed SharePoint Foundation 2010 Client Object Model Redistributable with the intent of creating a basic console app to retrieve the site name as demonstrated in Using the SharePoint Foundation 2010 Managed Client Object Model article on MSDN.

In the section detailing how a developer creates a console application, the article creates the following code:

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

My problem is that the namespace: Microsoft.Sharepoint.Client (squiggly underline underneath sharepoint) is not recognized. As a result, ClientContext and Web are not recognized. What do I do to get this to namespace to resolve?

转到项目的属性并修改“目标框架”以定位“.NET Framework 4”而不是“.NET Framework 4 Client Profile”

Make sure that assembly has been added to your References. You should be able to add it from your 12/14 hive.

According to Microsoft it can be found here:

%ProgramFiles%\\Common Files\\Microsoft Shared\\web server extensions\\14\\ISAPI

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM