4
votes

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?

2
Also, make sure you take a look at sharepoint.stackexchange.com when you have SharePoint questions. You are much more likely to get an answer there. - Abe Miessler

2 Answers

5
votes

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

4
votes

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