Namespace 'SharePoint' does not exist in t

2019-04-08 13:35发布

问题:

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?

回答1:

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?



回答2:

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



回答3:

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


回答4:

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



回答5:

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"



回答6:

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.