Fusion绑定后策略忽略bindingRedirect

时间:2014-04-23 19:12:33

标签: c# fusion assembly-binding-redirect

我有一个SignalR和Ext.net的项目。两者都需要Newtonsoft.Json。

SignalR需要Newtonsoft.Json 4.5.0.0,而Ext.net需要4.0.8.0。

我的绑定重定向根本不起作用。在我的web.config

<dependentAssembly>
  <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral"/>
  <bindingRedirect oldVersion="4.0.8.0" newVersion="4.5.0.0"/>
</dependentAssembly>

但是当它去绑定时

=== Pre-bind state information ===
LOG: DisplayName = Newtonsoft.Json, Version=4.0.8.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
 (Fully-specified)
LOG: Appbase = file:///C:/Users/*****/Documents/Visual Studio 2012/Projects/QuotaBuilder/branches/1Install/QMSSite/
LOG: Initial PrivatePath = C:\Users\*****\Documents\Visual Studio 2012\Projects\QuotaBuilder\branches\1Install\QMSSite\bin
Calling assembly : Ext.Net, Version=1.6.0.1867, Culture=neutral, PublicKeyToken=2e12ce3d0176cd87.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\*****\Documents\Visual Studio 2012\Projects\QuotaBuilder\branches\1Install\QMSSite\web.config
LOG: Using host configuration file: \\pacrl-fsrv02\userdata$\*****\My Documents\IISExpress\config\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=4.0.8.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/862fb004/45708817/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/862fb004/45708817/Newtonsoft.Json/Newtonsoft.Json.DLL.
LOG: Attempting download of new URL file:///C:/Users/*****/Documents/Visual Studio 2012/Projects/QuotaBuilder/branches/1Install/QMSSite/bin/Newtonsoft.Json.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

据我所知,后策略引用应该是重定向版本,而不是原始请求。但它完全被忽视了。我在使用这个项目之前遇到过这个问题,但在过去我已经能够得到它要求的版本,因为没有两个独立的依赖项。

2 个答案:

答案 0 :(得分:0)

将绑定重定向更改为:

<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>

答案 1 :(得分:0)

不要忘记在assemblyBinding元素中包含XML名称空间。

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">