“Could not load file or assembly 'Newtonsoft.Json, Version=4.0.3.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)”.
“无法加载文件或程序集'Newtonsoft.Json,Version = 4.0.3.0,Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed'或其依赖项之一。定位的程序集的清单定义与程序集引用不匹配。 (HRESULT异常:0x80131040)“。
'NewtonsoftJson.dll’ assembly is required for posting to twitter .The version used is 4.0.3.0.
发布到twitter需要'NewtonsoftJson.dll'程序集。使用的版本是4.0.3.0。
And the same assembly(but diff version 4.0.0.0) is used as the dependent assembly by facebook C# api(dll). However the above assembly(4.0.3.0) does not work for both the cases (ie for posting to twitter and for login to facebook). In order to solve it ,created a separate project for posting to twitter and reference the assembly(4.0.3.0) separately (in the project for twitter post).And another version(4.0.0.0) was added as reference in main project for facebook but still the error comes.If twitter project is disabled and ran then the facebook login works fine and vice vera.
并且相同的程序集(但是diff版本4.0.0.0)被用作facebook C#api(dll)的依赖程序集。但是,上述程序集(4.0.3.0)对两种情况都不起作用(即发布到twitter和登录facebook)。为了解决这个问题,创建了一个单独的项目,用于发布到twitter并单独引用程序集(4.0.3.0)(在twitter发布的项目中)。另外一个版本(4.0.0.0)作为参考添加在facebook的主项目中但仍然是错误来了。如果Twitter项目被禁用并运行,那么Facebook登录工作正常和副维拉。
I have done lot of research and tried the following.
我做了很多研究并尝试了以下方法。
delete temporary asp.net files clean solution restart computer
删除临时asp.net文件清理解决方案重启计算机
Even tried to uninstall the assembly from gac(however its not registered there).
甚至试图从gac卸载程序集(但它没有在那里注册)。
Please help me on this as its not working. Thanks, S
请帮助我,因为它无法正常工作。谢谢,S
3 个解决方案
#1
8
It's not clear what the relationships of the projects are, or when this error is occuring, but here's a guess.
目前尚不清楚项目的关系是什么,或者何时出现这种错误,但这是一个猜测。
You have 3 projects the facebook project (refs 4.0.0.0 version), twitter project (refs 4.0.3.0 version), and a main project that refs both of those projects. You may be able to build this solution, but when you run the assembly binding will fail. Why? because the default behavior is to copy assemblies locally before running. What happens is that the first project to build copies to bin (say twitter) then the second project builds (facebook), then main. However, at the end of this the 4.0.0.0 version is sitting bin folder. When you run, as soon as you invoke something from twitter that tries to use the problem assembly the bind fails because it longer has access to the 4.0.3.0 version of the assembly.
你有3个项目的facebook项目(参考4.0.0.0版本),twitter项目(参考4.0.3.0版本),以及一个主要项目,它们都是这两个项目的参考。您可以构建此解决方案,但在运行程序集时,绑定将失败。为什么?因为默认行为是在运行之前在本地复制程序集。会发生的是第一个将副本构建到bin(比如twitter)的项目,然后第二个项目构建(facebook),然后是main。但是,在此结束时,4.0.0.0版本是坐在bin文件夹中。当您运行时,只要您从twitter调用某些尝试使用问题程序集的内容,绑定就会失败,因为它可以访问4.0.3.0版本的程序集。
There are a couple of ways around this. One is register both assemblies in the GAC. If that isn't doable then look into assembly binding redirection in your config file. Another is to register for the AssemblyResolve event and load the assembly programmatically.
有几种方法可以解决这个问题。一个是在GAC中注册两个程序集。如果这不可行,那么请查看配置文件中的程序集绑定重定向。另一种方法是注册AssemblyResolve事件并以编程方式加载程序集。
#2
8
Add the following to your app.config file:
将以下内容添加到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-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
within your <configuration></configuration>
tags
在
#3
0
Install package Newtonsoft in all projects.
在所有项目中安装Newtonsoft软件包。
Install-Package Newtonsoft.Json -Version 8.0.3
#1
8
It's not clear what the relationships of the projects are, or when this error is occuring, but here's a guess.
目前尚不清楚项目的关系是什么,或者何时出现这种错误,但这是一个猜测。
You have 3 projects the facebook project (refs 4.0.0.0 version), twitter project (refs 4.0.3.0 version), and a main project that refs both of those projects. You may be able to build this solution, but when you run the assembly binding will fail. Why? because the default behavior is to copy assemblies locally before running. What happens is that the first project to build copies to bin (say twitter) then the second project builds (facebook), then main. However, at the end of this the 4.0.0.0 version is sitting bin folder. When you run, as soon as you invoke something from twitter that tries to use the problem assembly the bind fails because it longer has access to the 4.0.3.0 version of the assembly.
你有3个项目的facebook项目(参考4.0.0.0版本),twitter项目(参考4.0.3.0版本),以及一个主要项目,它们都是这两个项目的参考。您可以构建此解决方案,但在运行程序集时,绑定将失败。为什么?因为默认行为是在运行之前在本地复制程序集。会发生的是第一个将副本构建到bin(比如twitter)的项目,然后第二个项目构建(facebook),然后是main。但是,在此结束时,4.0.0.0版本是坐在bin文件夹中。当您运行时,只要您从twitter调用某些尝试使用问题程序集的内容,绑定就会失败,因为它可以访问4.0.3.0版本的程序集。
There are a couple of ways around this. One is register both assemblies in the GAC. If that isn't doable then look into assembly binding redirection in your config file. Another is to register for the AssemblyResolve event and load the assembly programmatically.
有几种方法可以解决这个问题。一个是在GAC中注册两个程序集。如果这不可行,那么请查看配置文件中的程序集绑定重定向。另一种方法是注册AssemblyResolve事件并以编程方式加载程序集。
#2
8
Add the following to your app.config file:
将以下内容添加到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-4.5.0.0" newVersion="4.5.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
within your <configuration></configuration>
tags
在
#3
0
Install package Newtonsoft in all projects.
在所有项目中安装Newtonsoft软件包。
Install-Package Newtonsoft.Json -Version 8.0.3