我正在創建一個新的MVC 4網站,並且我想使用Unity.MVC3庫來整合MVC中內置的DependencyResolver內容。Unity的綁定重定向不起作用
我也想引用一些舊的,更大的項目的一些數據訪問DLL。
我的問題是,Unity.MVC3和較舊的DLL分別針對不同版本的Unity,1.2.0.0和2.1.505.0進行編譯。我想在我的web.config文件中創建一個綁定重定向,像這樣:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersions="1.2.0.0-2.1.505.0" newVersion="2.1.505.0" />
</dependentAssembly>
不過,我還是得到了以下錯誤:
Could not load file or assembly 'Microsoft.Practices.Unity, Version=1.2.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
我打開集綁定日誌記錄,最後兩行狀態:
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
爲什麼我的綁定重定向不被尊重?有沒有辦法來覆蓋其檢查主要版本衝突?
您能否在融合日誌中看到綁定重定向是否實際上被使用? – fsimonazzi