2014-10-09 39 views
2

在這個Selenium測試項目中,我直接參考了Unity 3.0.0.0。裝配綁定 - 使用Unity的錯誤版本,但爲什麼?

我引用了其他引用Unity的2.505.0.2的DLL。

我有這個在我的app.config:

<runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-1.0.0.0" newVersion="1.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="Microsoft.Practices.Unity" publicKeyToken="31bf3856ad364e35" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" /> 
     </dependentAssembly> 
     <dependentAssembly> 
     <assemblyIdentity name="AutoMapper" publicKeyToken="be96cd2c38ef1005" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-3.2.1.0" newVersion="3.2.1.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 

我預期使用統一的V3,但它一直試圖用舊的。綁定日誌是:

Assembly manager loaded from: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll 
Running under executable C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE\COMMONEXTENSIONS\MICROSOFT\TESTWINDOW\vstest.executionengine.x86.exe 
--- A detailed error log follows. 

=== Pre-bind state information === 
LOG: User = INT\UKTHJHAR 
LOG: DisplayName = Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
(Fully-specified) 
LOG: Appbase = file:///C:/Audatex/Retail/Development/Server/AudaRetailAdministration.AutomatedUITests/bin/Debug 
LOG: Initial PrivatePath = NULL 
Calling assembly : AudaRetailAdministration.AutomatedUITests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\Audatex\Retail\Development\Server\AudaRetailAdministration.AutomatedUITests\bin\Debug\AudaRetailAdministration.AutomatedUITests.dll.config 
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. 
LOG: Post-policy reference: Microsoft.Practices.Unity, Version=2.1.505.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 
LOG: Attempting download of new URL file:///C:/Audatex/Retail/Development/Server/AudaRetailAdministration.AutomatedUITests/bin/Debug/Microsoft.Practices.Unity.DLL. 
WRN: Comparing the assembly name resulted in the mismatch: Major Version 
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated. 

回答

0

我認爲程序集綁定僅適用於直接引用。

可能是防止使用不同版本的同一總成中的單個應用程序(或應用領域也許?)

如果您使用的一個至極的其他組件的版本編譯的一個組成部分通過引用應用程序,該組件的加載將失敗。

如果反編譯引用較舊版本Unity的程序集,您將看到Unity版本在程序集元數據中以某種方式硬編碼。在這個崗位 Why is assembly binding redirect not working in my web site?

我也通過在應用程序及其組件使用相同的組件版本解決問題

同樣的問題。它可能不適合你。

此問題是使用GAC發佈的複雜應用程序的缺點。現在,人們傾向於使用塊組來輕鬆管理組件依賴關係。

+0

感謝您花時間回答這個問題。儘管如此,我並不完全相信你的回答,因爲我已經完成了完成此項目的項目,並重定向了未直接引用的程序集。 – 2014-10-09 12:25:55

+0

在其他項目中,這些程序集是否也被強調命名?我確實得到了這個具有這個特定配置的項目的錯誤。 – Bombinosh 2014-10-09 12:47:52

相關問題