Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 432
MedicineMan Avatar asked Jan 19 '23 23:01

MedicineMan


2 Answers

go to properties for the project and modify "Target Framework" to target ".NET Framework 4" instead of ".NET Framework 4 Client Profile"

like image 148
MedicineMan Avatar answered Apr 27 '23 08:04

MedicineMan


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

like image 26
Abe Miessler Avatar answered Apr 27 '23 08:04

Abe Miessler