7

So I am starting to learn C#, like literally just started learning, and coming from a Java background, it doesn't look too bad. However, I have a question. 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 that "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 that 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?

agent-j
  • 27,335
  • 5
  • 52
  • 79
This 0ne Pr0grammer
  • 2,632
  • 14
  • 57
  • 81
  • 1
    See if this link helps answer your question http://stackoverflow.com/questions/1311519/sharepoint-development-using-visual-studio-express – Brian Hoover Aug 03 '11 at 20:11
  • Are you sure the namespace is correct? Maybe it isn't Microsoft.SharePoint.Client. – Dustin Davis Aug 03 '11 at 20:20
  • @DustinDavis Yeah, it's straight from the tutorial, and it's what's stored in "References". – This 0ne Pr0grammer Aug 03 '11 at 20:24
  • When you type Microsoft. what does intellisense give you? – Dustin Davis Aug 03 '11 at 20:47
  • @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. – This 0ne Pr0grammer Aug 03 '11 at 20:54
  • 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? – Dustin Davis Aug 03 '11 at 21:07
  • 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.5 – Dustin Davis Aug 03 '11 at 21:09
  • @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. – This 0ne Pr0grammer Aug 03 '11 at 21:12
  • 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. – Dustin Davis Aug 03 '11 at 21:16

7 Answers7

9

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

Mahika
  • 662
  • 2
  • 11
  • 21
  • 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. – Matthew R Jul 11 '13 at 13:47
  • Adding reference is very basic and simple answer. This answer makes it correct. Because error does not say anything about framework and you can see the dll in reference. So this is life saver... – PM. Oct 30 '14 at 11:15
8
  1. Add required references to the solution.
  2. Make sure that the target framework is 4 for SP2013(3.5 for SP2010).
Ganesha
  • 342
  • 1
  • 3
  • 8
8

Did you add the references to the Microsoft.SharePoint.Client assembly and Microsoft.SharePoint.Client.Runtime assembly as noted near the beginning of that tutorial?

Powerlord
  • 87,612
  • 17
  • 125
  • 175
  • @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.Runtime` – This 0ne Pr0grammer Aug 03 '11 at 20:16
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

agent-j
  • 27,335
  • 5
  • 52
  • 79
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"

TylerH
  • 20,799
  • 66
  • 75
  • 101
JAiro
  • 5,914
  • 2
  • 22
  • 21
1

Thanks to those who mentioned the 4.0 framework.

Mine defaulted to .NET Framework 4 Client Profile (and I have no idea what that means), and the Namespaces looked good in Intellisense, but the build would say they weren't found! Crazy.

Nic
  • 12,220
  • 20
  • 77
  • 105
0

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

bresleveloper
  • 5,940
  • 3
  • 33
  • 47