【发布时间】:2018-08-06 19:33:40
【问题描述】:
我有一个 Newtonsoft 的 FileLoadException,当我安装 11.0.2.0 时正在寻找版本 6.0.0.0。 packages.config 设置为查找较新的版本,web.config 也是如此。参考中的 .dll 版本是 11,我的解决方案之外的框架文件夹中的临时 ASP 文件也是如此。我已经尝试强制卸载 newtonsoft 并在包管理器控制台中安装最新版本。
在代码内外,我找不到任何定义版本 6.0.0.0 的地方。这是在哪里设置的?
这是融合日志(你可以看到它正在尽一切可能在失败之前获得匹配):
=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed(Fully-specified)
LOG: Appbase = file:///C:/Repos/MyProjectPath/
LOG: Initial PrivatePath = C:\Repos\MyProjectPath\bin
Calling assembly : System.Net.Http.Formatting, Version=5.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Repos\MyProjectPath\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyProjectFolder/20c630f1/c09fb4a6/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/MyProjectFolder/20c630f1/c09fb4a6/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Repos/MyProjectPath/bin/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
【问题讨论】:
-
您是否尝试过在您的 app/web.config 中使用
<bindingRedirect/>元素?或者,您是否看过这是否是这些元素之一的结果? -
对它的任何引用是否将
Specific Version设置为True(选择引用并在“属性”窗口中查看)。 -
对 6.0 版的引用可能是间接的。请求程序集是 System.Net.Http.Formatting。要么你引用这个程序集,要么你正在使用的东西是。解决方案是在从 6.0 映射到 11.0 的配置文件中设置程序集绑定重定向。通常这是在automatically 完成的,因此您可能需要检查您的项目和/或 IDE 设置。
-
web.config 文件有一个绑定重定向,指定 oldVersion="0.0.0.0-11.0.0.0" newVersion="11.0.0.0"。 @Richardissimo,具体版本设置为true。
-
跟踪表明这不起作用,它仍在寻找 6.0.0.0。只需确保您编辑了正确的 web.config 文件并在您的问题中显示其完整内容。
标签: c# .net-assembly fusion