我遇到了一个问题,我在尝试加载旧版本的dll时遇到错误,这个版本甚至不再在机器上了。
无法加载文件或程序集' Newtonsoft.Json,Version = 6.0.0.0, Culture = neutral,PublicKeyToken = 30ad4fe6b2a6aeed'或其中一个 依赖。定位程序集的清单定义没有 匹配程序集引用。 (HRESULT异常:0x80131040)
我已经在webconfig中进行了重定向来处理这个问题:
<dependentAssembly>
<assemblyIdentity name="NewtonSoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
解决方案中没有对6.0.0.0版本的引用。也许依赖?如果是这样,我不知道如何让运行时间告诉我谁是有罪的部分。
为什么这仍然是错误的?
答案 0 :(得分:3)
原来答案就在我面前。 assemblyBinding标记有一个applyTo属性,指定每个.Net框架版本应重定向哪些版本。
assemblyBinding appliesTo="v2.0.50727"
由于某种原因,它被设置为v2.0 - 应用程序正在运行v4.0,因此重定向不适用的地方。删除属性可以解决问题。
<runtime>
<assemblyBinding>
<dependentAssembly>
<assemblyIdentity name="NewtonSoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-10.0.0.0" newVersion="10.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>