Namespace 'SharePoint' does not exist in the namespace 'Microsoft'
Asked Answered
F

6

7

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?

Fibro answered 3/8, 2011 at 20:7 Comment(9)
See if this link helps answer your question #1312019Dolce
Are you sure the namespace is correct? Maybe it isn't Microsoft.SharePoint.Client.Stopwatch
@DustinDavis Yeah, it's straight from the tutorial, and it's what's stored in "References".Fibro
When you type Microsoft. what does intellisense give you?Stopwatch
@DustinDavis Wait, I just re-started Visual Studio, and I saw "SharePoint" under Microsoft. Then when I went to build the project, it said that it couldn't find the namespace. Idk what's going on.Fibro
Instead of the using, use the fully qualified type name. Microsoft.SharePoint.Client.MyObject and see what happens. Is this a single project or multiple projects?Stopwatch
Which versino of express are you using? If you can't change the target framework then I think that's the problem. It's defaulting to 4.0 and the tut says you must use 3.5Stopwatch
@DustinDavis I found the problem. I don't understand why this is the case, but essentially I had to change the directory the DLLs were stored in. I had them stored in my documents, but I needed to move them to the "reference assemblies" folder where all the other dll's where stored and add them from there. Seems to work now. I still very much appreciate your help, as well as everyone else who contributed. If you want to post some sort of answer or something, I'd be happy to give you credit.Fibro
I was going to say I just tried this and I got it to work with .net 4 and 3.5. Documents is a library and will limit access so that makes sense. Glad you figured it out.Stopwatch
B
9

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.

Bealle answered 3/8, 2011 at 20:11 Comment(1)
@R. Bemrose Right, I added both of those and under references in the right panel I see I have Microsoft.SharePoint.Client and Microsoft.SharePoint.Client.RuntimeFibro
D
9

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

Damaraland answered 19/6, 2013 at 11:54 Comment(1)
Don't use .NET 3.5 Framework Client profile because the SharePoint client-side object model has a reference to System.Web which isn't included in the CP subset.Pendent
R
7
  1. Add required references to the solution.
  2. Make sure that the target framework is 4 for SP2013(3.5 for SP2010).
Ribonuclease answered 28/6, 2014 at 12:17 Comment(3)
It was the .net version that did it for me!Alkalosis
For those who don't know, Target Framework is an option when you create your projectManipular
This just repeats existing answers posted a year or three years prior.Chessy
U
5

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

Unmask answered 3/8, 2011 at 20:12 Comment(0)
O
2

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"

Orangy answered 3/8, 2011 at 20:13 Comment(0)
M
-1

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

Motorcar answered 13/3, 2022 at 20:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.