2017-01-23 59 views
1

我編寫了類庫以支持使用NLog和log4net和Common.Logging編寫日誌。當我和項目來測試我得到錯誤Could not load file or assembly 'Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)無法加載文件或程序集Common.Logging

FlushLog:

=== Pre-bind state information === 
LOG: DisplayName = Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e 
(Fully-specified) 
LOG: Appbase = file:///C:/Source/Hits2000/Web-Applications/WinhitsWebApi/WinhitsWebApi.ApiService/ 
LOG: Initial PrivatePath = C:\Source\Hits2000\Web-Applications\WinhitsWebApi\WinhitsWebApi.ApiService\bin 
Calling assembly : Common.Logging.Log4Net1211, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e. 
=== 
LOG: This bind starts in default load context. 
LOG: Using application configuration file: C:\Source\Hits2000\Web-Applications\WinhitsWebApi\WinhitsWebApi.ApiService\web.config 
LOG: Using host configuration file: C:\Users\Administrator\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: Common.Logging, Version=3.3.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f19f3155/f95cde26/Common.Logging.DLL. 
LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/root/f19f3155/f95cde26/Common.Logging/Common.Logging.DLL. 
LOG: Attempting download of new URL file:///C:/Source/Hits2000/Web-Applications/WinhitsWebApi/WinhitsWebApi.ApiService/bin/Common.Logging.DLL. 
WRN: Comparing the assembly name resulted in the mismatch: Minor Version 
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated. 

請幫我解決這個問題

回答

0

我曾在我的.Net程序類似的例外。我將一些nuget軟件包升級並降級,這給我帶來了錯誤和輕微的頭痛。

我在App.config中

 <dependentAssembly> 
      <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" /> 
      <bindingRedirect oldVersion="0.0.0.0-3.4.0.0" newVersion="3.4.0.0" /> 
     </dependentAssembly> 

改變了這一爲此

 <dependentAssembly> 
      <assemblyIdentity name="Common.Logging" publicKeyToken="af08829b84f0328e" culture="neutral" /> 
      <bindingRedirect oldVersion="0.0.0.0-3.3.1.0" newVersion="3.3.1.0" /> 
     </dependentAssembly> 

版本號發生了變化,由於升級的NuGet和降級期間沒有恢復。

相關問題