This 0ne Pr0grammer
This 0ne Pr0grammer

Reputation: 2662

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?

Upvotes: 7

Views: 34951

Answers (6)

Powerlord
Powerlord

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:

  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.

Upvotes: 9

bresleveloper
bresleveloper

Reputation: 6066

for anyone developing for SP2019, you need to target .net 4.5

Upvotes: -1

JAiro
JAiro

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

Ganesha
Ganesha

Reputation: 340

  1. Add required references to the solution.
  2. Make sure that the target framework is 4 for SP2013(3.5 for SP2010).

Upvotes: 7

Mahika
Mahika

Reputation: 662

Make sure that the target framework is 3.5 and not 4 i.e for SP2010

Upvotes: 9

agent-j
agent-j

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

Related Questions