Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 棘手的程序集版本不兼容_C#_Json.net_Sharpmap - Fatal编程技术网

C# 棘手的程序集版本不兼容

C# 棘手的程序集版本不兼容,c#,json.net,sharpmap,C#,Json.net,Sharpmap,我最近在我的一个项目中添加了SharpMap。然后,同一解决方案中的另一个项目抛出以下内容: An exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll but was not handled in user code Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Cu

我最近在我的一个项目中添加了SharpMap。然后,同一解决方案中的另一个项目抛出以下内容:

An exception of type 'System.IO.FileLoadException' occurred in mscorlib.dll but was not handled in user code

Additional information: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我在搜索解决方案时发现:

但事实上,这并不能解决问题:

Update-Package : Unable to resolve dependencies. 'Newtonsoft.Json 7.0.1' is not compatible with 'SharpMap 1.1.0 constraint: Newtonsoft.Json (= 4.5.11)'.
At line:1 char:16
+  Update-Package <<<<  Newtonsoft.Json
    + CategoryInfo          : NotSpecified: (:) [Update-Package], Exception
    + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
更新包:无法解析依赖项。'Newtonsoft.Json 7.0.1”与“SharpMap 1.1.0约束:Newtonsoft.Json(=4.5.11)”不兼容。
第1行字符:16

+更新包您需要添加对程序集Newtonsoft.Json特定版本的引用,所需版本为4.5.11。您添加的版本是7.0

由于SharpMap 1.1.0.0依赖于Newtonsoft.Json版本4.5.11,因此您应该使用数据包管理器控制台和以下命令更新您的项目

Update-Package Newtonsoft.Json -version 4.5.11
这将卸载当前版本的Newtonsoft.Json,并安装(旧)版本4.5.11

另一个解决方法是使用程序集版本重定向,方法是将以下内容添加到app.config

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

但是,只有当您确信SharpMap 1.1.0.0能够与新版本的Newtonsoft.Json一起使用时,才应该使用此选项