无法加载文件或程序集'Microsoft.SharePoint,Version = 15.0.0.0

时间:2017-07-05 10:29:56

标签: c# sharepoint

这是我使用的代码。 我添加了Microsoft.SharePoint.dll。

using Microsoft.SharePoint.Client;
using System.Web.Script.Serialization;
using Microsoft.SharePoint;

    class
    {          
      SPSite site = new SPSite(siteUrl);
    }

错误显示如下 :

 Could not load file or assembly 'Microsoft.SharePoint, Version=15.0.0.0,
 Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. 
 The system cannot find the file specified.

1 个答案:

答案 0 :(得分:2)

1)检查项目中的引用。是否有Microsoft.SharePoint参考?

2)如果有引用并且没有损坏,请通过打开库属性来检查版本。

2.1)如果您引用了较新的版本,请在app config中添加一个带有bindingRedirect的程序集绑定,例如:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
  <dependentAssembly>
    <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
    <bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
  </dependentAssembly>
</assemblyBinding>

3)启用Fusion日志How to enable assembly bind failure logging (Fusion) in .NET并阅读日志。