Search code examples
c#.netsharepointnew-operatorsharepoint-clientobject

Namespace 'SharePoint' does not exist in the namespace 'Microsoft'


I am following this tutorial on using the client-object model. And just starting from the top, I added the references, but using Microsoft.SharePoint.Client; keeps giving me the error:

The namespace 'SharePoint' does not exist in the namespace 'Microsoft'

But I clearly see it on the right side panel. So looking at the instructions, the only difference I can think of is the fact that I am using Visual Studio Express and thus do not have the option to choose which framework to use when creating a new project. Other than that, I don't know what the problem might be.

Does anyone have any ideas on what else I could be missing or how to correct this problem?


Solution

  • You need to add the references to the Microsoft.SharePoint.Client assembly and Microsoft.SharePoint.Client.Runtime assembly as noted near the beginning of that tutorial:

    1. The classes that you use in a client object model application are located in Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll. As mentioned, before you add the references, you must copy those assemblies from the server that runs SharePoint Foundation to the client development computer.

    2. On the Project menu, click Add Reference to open the Add Reference dialog box.

    3. Select the Browse tab, navigate to the location where you put the Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll. Select both DLLs, and then click OK.