[英]Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies?
when I am debugging i faced an exception at below point. 当我调试时,我在下面遇到了一个异常。
var connection = new HubConnection("http://localhost:8080/");
Exception:
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)
I had created a folder I dumped my serverHub.exe(console App) and a client module which is of winforms. 我创建了一个文件夹,转储了serverHub.exe(控制台应用程序)和一个Winforms客户端模块。 In the client side when I tried calling the above step mentioned I got the exception.
在客户端,当我尝试调用上述步骤时,出现了异常。
First I had installed Newtonsoft.Json of version=6.0.0.0, later I updated it to version=9.0.1. 首先,我安装了版本= 6.0.0.0的Newtonsoft.Json,后来将其更新为版本= 9.0.1。 Now I copied the dll's
(Microsoft.Asp.Net.Client.dll, Newtonsoft.Json.dll along with other dll's required)
required into the common folder I had created. 现在,将所需的dll
(Microsoft.Asp.Net.Client.dll, Newtonsoft.Json.dll along with other dll's required)
复制到我创建的公用文件夹中。 This is when i started facing the exception. 这是我开始面对例外的时候。
Now the references (Newtonsoft.Json.dll, Microsoft.Asp.Net.Client.dll)
in my project are referring to the folder I had newly created where I dumped the copied dlls from "packages" location. 现在,我项目中的引用
(Newtonsoft.Json.dll, Microsoft.Asp.Net.Client.dll)
引用了我新创建的文件夹,在该文件夹中,我从“程序包”位置转储了复制的dll。
Again I removed these references and downloaded the Nuget packages from package manager(Microsoft.Asp.Net.Client.dll-version:2.2.1 & Newtonsoft.Json.dll-9.0.1). 我再次删除了这些引用,并从程序包管理器(Microsoft.Asp.Net.Client.dll-version:2.2.1&Newtonsoft.Json.dll-9.0.1)下载了Nuget程序包。 and the references are now referred from
package
location. 现在可以从
package
位置引用这些引用。 Now I tried building my application and now it is working fine. 现在,我尝试构建我的应用程序,现在它可以正常工作。
App.config(Client's): App.config(客户端):
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<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>
</runtime>
</configuration>
App.config(server): App.config(服务器):
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.1.0.0" newVersion="3.1.0.0" />
</dependentAssembly>
<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>
If I start referring to a different location where I will copy all the dll's which are installed rather than of a default "Packages" location under solution directory I am facing the above exception.Can't we make the dll's to refer from a different location rather than default "packages" location? 如果我开始引用其他位置,而不是解决方案目录下默认的“ Packages”位置,则将复制所有已安装的dll,那么我将面临上述异常。我们不能使dll从其他位置引用而不是默认的“包”位置? If yes please help where I am doing wrong.
如果是,请帮助我做错了。
Can any one please help me. 谁能帮帮我吗。
I would try to change binding redirect to <bindingRedirect oldVersion="0.0.0.0-9.0.1.0" newVersion="9.0.1.0" /> 我会尝试将绑定重定向更改为<bindingRedirect oldVersion =“ 0.0.0.0-9.0.1.0” newVersion =“ 9.0.1.0” />
If this does not help try to check by this tool the new location where you run your executables in order to see what actually is missed: https://stackoverflow.com/a/44251000/2819746 如果这样做没有帮助,请尝试使用此工具检查运行可执行文件的新位置,以查看实际缺少的内容: https : //stackoverflow.com/a/44251000/2819746
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.