Reputation: 2662
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?
Upvotes: 7
Views: 34951
Reputation: 88806
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:
The classes that you use in a client object model application are located in
Microsoft.SharePoint.Client.dll
andMicrosoft.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.On the Project menu, click Add Reference to open the Add Reference dialog box.
Select the Browse tab, navigate to the location where you put the
Microsoft.SharePoint.Client.dll
andMicrosoft.SharePoint.Client.Runtime.dll
. Select both DLLs, and then click OK.
Upvotes: 9
Reputation: 6066
for anyone developing for SP2019, you need to target .net 4.5
Upvotes: -1
Reputation: 6009
Take a look at the references in your project and make sure you have the reference to the assembly. If it is not there try adding it, right click -->add reference and find "Microsoft.SharePoint.Client"
Upvotes: 2
Reputation: 340
Upvotes: 7
Reputation: 27943
Did you do this part of the tutorial you mentioned above?
To build the application, you must add references to two assemblies, Microsoft.SharePoint.Client.dll and Microsoft.SharePoint.Client.Runtime.dll. Installing SharePoint Foundation installs these assemblies on the server. The two assemblies are located in the following directory:
%ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\ISAPI
Upvotes: 5