Reference to Microsoft.SharePoint.dll

2019-07-01 15:31发布

问题:

I have a server that Shrepoint installed on it.

I want to test this code:

SPUtility.GetLocalizedString Method

When I add reference to Microsoft.SharePoint.dll I can resolve SPSite and ... .The problem is When I want to build the project it does not recognize using Microsoft.SharePoint any more:

and I get this error:

Error 13 The type or namespace name 'SharePoint' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

where is the problem? I add reference to Microsoft.SharePoint.dll but in build time it does not works

回答1:

Microsoft.SharePoint.dll from SharePoint 2010 use Framework 3.5 but Microsoft.SharePoint.dll from SharePoint 2013 use Framework 4.0

try it.



回答2:

Change Visual Studio project solution properties platform target to x64 and the target framework to .NET Framework 3.5.



回答3:

Try to use this namespace:

using Microsoft.SharePoint.Utilities

In the link you gave, it says that the method resides in Namespace Microsoft.SharePoint.Utilities instead of Microsoft.SharePoint. This is just a guess maybe work, haven't tested it,