Asp.net Json程序集冲突-DLL地狱

Asp.net Json程序集冲突-DLL地狱,asp.net,json.net,Asp.net,Json.net,尝试升级到Newtonsoft.Json版本8时,我不断得到“无法加载文件或程序集'Newtonsoft.Json,version=6.0.0.Culture=neutral,PublicKeyToken=30ad4fe6b2a6eed'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。” 我的项目(或我的解决方案中的任何项目)不再引用版本6。我浏览了互联网和堆栈交换,但没有一个建议有效。我的web.config文件中列出了以下内容: 该项目在我的本地环境中运行良好。在我推到Main

尝试升级到Newtonsoft.Json版本8时,我不断得到“无法加载文件或程序集'Newtonsoft.Json,version=6.0.0.Culture=neutral,PublicKeyToken=30ad4fe6b2a6eed'或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。”

我的项目(或我的解决方案中的任何项目)不再引用版本6。我浏览了互联网和堆栈交换,但没有一个建议有效。我的web.config文件中列出了以下内容:


该项目在我的本地环境中运行良好。在我推到Main并将其部署到QA之后,它在QA中爆炸。我把Main拉到我的本地机器上,它也会因为同样的错误而崩溃

我很沮丧。如果你有什么建议,除了网上已经提到的,我很高兴听到

我尝试过融合(没有帮助)

编辑:

融合误差日志

*** Assembly Binder Log Entry  (5/17/2016 @ 1:48:49 PM) ***

The operation failed.
Bind result: hr = 0x80131040. No description available.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\WINDOWS\SysWOW64\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
 (Fully-specified)
LOG: Appbase = file:///C:/Development/MyApp/Main/Services/MyAppInternal/MY.MyApp.Services.REST/
LOG: Initial PrivatePath = C:\Development\MyApp\Main\Services\MyAppInternal\MY.MyApp.Services.REST\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\68a38e3a
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\68a38e3a
LOG: AppName = fd029416
Calling assembly : MY.MyApp.Services.REST, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Development\MyApp\Main\Services\MyAppInternal\MY.MyApp.Services.REST\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/68a38e3a/fd029416/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/68a38e3a/fd029416/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Development/MyApp/Main/Services/MyAppInternal/MY.MyApp.Services.REST/bin/Newtonsoft.Json.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Development\MyApp\Main\Services\MyAppInternal\MY.MyApp.Services.REST\bin\Newtonsoft.Json.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

*** Assembly Binder Log Entry  (5/17/2016 @ 1:48:49 PM) ***

The operation failed.
Bind result: hr = 0x80131040. No description available.

Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Running under executable  C:\WINDOWS\SysWOW64\inetsrv\w3wp.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
 (Fully-specified)
LOG: Appbase = file:///C:/Development/MyApp/Main/Services/MyAppInternal/MY.MyApp.Services.REST/
LOG: Initial PrivatePath = C:\Development\MyApp\Main\Services\MyAppInternal\MY.MyApp.Services.REST\bin
LOG: Dynamic Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\68a38e3a
LOG: Cache Base = C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\68a38e3a
LOG: AppName = fd029416
Calling assembly : MY.MyApp.Services.REST, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Development\MyApp\Main\Services\MyAppInternal\MY.MyApp.Services.REST\web.config
LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework\v4.0.30319\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: GAC Lookup was unsuccessful.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/68a38e3a/fd029416/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/68a38e3a/fd029416/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Development/MyApp/Main/Services/MyAppInternal/MY.MyApp.Services.REST/bin/Newtonsoft.Json.DLL.
LOG: Assembly download was successful. Attempting setup of file: C:\Development\MyApp\Main\Services\MyAppInternal\MY.MyApp.Services.REST\bin\Newtonsoft.Json.dll
LOG: Entering download cache setup phase.
LOG: Assembly Name is: Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: The assembly reference did not match the assembly definition found.
ERR: Setup failed with hr = 0x80131040.
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
编辑:

我浏览了解决方案中的每个项目文件,它们都以以下方式引用Newtonsoft.Json:

<Reference Include="Newtonsoft.Json, Version=8.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
  <HintPath>..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll</HintPath>
  <Private>True</Private>
</Reference>

..\packages\Newtonsoft.Json.8.0.3\lib\net45\Newtonsoft.Json.dll
真的

嗯,这不是我想要的答案,但它解决了我的问题。我将Newtonsoft.Json回滚到版本6。这消除了运行时错误。我真的不能再浪费更多的时间来解决一个本不应该成为问题的问题了

在进行所有故障排除时,我发现我的许多第三方依赖项依赖于Newtonsoft.Json(在各种不同的版本中)。WebApi 2.2需要版本6。有些人想要版本5


bindingRedirect创建的全部原因就是这种版本需求的混合。所以我的问题是bindingRedirect没有按设计的那样工作。

好吧,这不是我想要的答案,但它解决了我的问题。我将Newtonsoft.Json回滚到版本6。这消除了运行时错误。我真的不能再浪费更多的时间来解决一个本不应该成为问题的问题了

在进行所有故障排除时,我发现我的许多第三方依赖项依赖于Newtonsoft.Json(在各种不同的版本中)。WebApi 2.2需要版本6。有些人想要版本5


bindingRedirect创建的全部原因就是这种版本需求的混合。因此,我的问题实际上是bindingRedirect没有按设计的那样工作。

我也遇到了同样的问题:一切都在开发过程中工作,而我在部署到预处理/生产服务器时遇到了这个错误。My web.config已具有bindingRedirect


在NuGet中将所有包更新为最新版本并再次重新部署后,问题神奇地解决了。显然,它使用了VisualStudio附带的版本的软件包,并对其进行了更新,以某种方式解决了问题。

我也遇到了同样的问题:一切都在开发过程中工作,在部署到预处理/生产服务器时,我遇到了这个错误。My web.config已具有bindingRedirect


在NuGet中将所有包更新为最新版本并再次重新部署后,问题神奇地解决了。显然,它使用了VisualStudio附带的版本的软件包,并对其进行了更新,以某种方式解决了问题。

您是否查看了其他环境中的配置文件,以确保其中包含绑定重定向?错误告诉您需要知道的一切:应用程序中的某些程序集,无论其配置中是否有重定向,仍然链接到版本6。查看“Main”(源代码管理中的分支?),使用外部编辑器在文件中查找,使用Fusion日志确定请求版本6的调用程序集。另一方面,也可能是某些引用拉入了版本6(因为它没有更新到8),而版本6最终出现在您的bin目录中,导致您的主程序集无法加载其引用。是的,我甚至在package manager控制台中完成了“Get Project-All | Add BindingRedirect”。我已经把所有的东西都擦干净了,又把它拿回来了,删除了垃圾箱,做了一次清理,做了一次重建。@CodeCaster是的,我理解这个错误的意思。我找不到它仍然引用旧版本的位置。即使是这样,为什么web.config文件中的bindingRedirect没有完成它的工作呢?您只粘贴了一半的错误。“清单不匹配”表示某些程序集链接到6,运行时只能找到8,并且它们不可交换。您是否查看了其他环境中的配置文件,以确保其中包含绑定重定向?错误告诉您需要了解的所有信息:应用程序中的某个程序集,无论其配置中是否有重定向,仍然链接到版本6。查看“Main”(源代码管理中的分支?),使用外部编辑器在文件中查找,使用Fusion日志确定请求版本6的调用程序集。另一方面,也可能是某些引用拉入了版本6(因为它没有更新到8),而版本6最终出现在您的bin目录中,导致您的主程序集无法加载其引用。是的,我甚至在package manager控制台中完成了“Get Project-All | Add BindingRedirect”。我已经把所有的东西都擦干净了,又把它拿回来了,删除了垃圾箱,做了一次清理,做了一次重建。@CodeCaster是的,我理解这个错误的意思。我找不到它仍然引用旧版本的位置。即使是这样,为什么web.config文件中的bindingRedirect没有完成它的工作呢?您只粘贴了一半的错误。“清单不匹配”意味着某些程序集是针对6链接的,而运行时只能找到8,并且它们是不可交换的。