无法加载文件或程序集“log4net,版本=2.0.8.0,文化=中性,PublicKeyToken=1b44e1d426115821"或其依赖项之一 [英] Could not load file or assembly 'log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies
问题描述
我发现了几个与此问题相关的线程,但没有一个解决了我的问题.
I found several threads relating this issue, but none of those solved my issue.
我之前一直在我的 ASP.NET
服务中使用 log4net version 1.2.10.0
.我已将其更新到当前版本 log4net v2.0.8.0
,由于某些第三方库,我还在 web.config
中添加了以下几行以支持/重定向旧版本.
I have been previously using log4net version 1.2.10.0
in my ASP.NET
services. I have updated it to current version which is log4net v2.0.8.0
, due to some third party libraries I also added the following lines in my web.config
to to support/redirect old versions.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-9.0.0.0" newVersion="9.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="1b44e1d426115821" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.2.10.0" newVersion="2.0.8.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
我也对这些消息感到困惑内部异常: ((System.IO.FileLoadException)ex.InnerException.InnerException).Message
I am also confused in these Messages Inner Exception: ((System.IO.FileLoadException)ex.InnerException.InnerException).Message
无法加载文件或程序集log4net,版本=1.2.10.0,Culture=neutral, PublicKeyToken=1b44e1d426115821' 或其中之一依赖关系.定位的程序集的清单定义没有匹配程序集引用.(来自 HRESULT 的异常:0x80131040)
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
异常信息:
无法加载文件或程序集log4net,版本=2.0.8.0,Culture=neutral, PublicKeyToken=1b44e1d426115821' 或其中之一依赖关系.定位的程序集的清单定义没有匹配程序集引用.(来自 HRESULT 的异常:0x80131040)
Could not load file or assembly 'log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=1b44e1d426115821' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
可能是以下几行指向 FusionLog 中的问题
警告:比较程序集名称导致不匹配:PUBLIC KEY令牌错误:无法完成程序集设置 (hr = 0x80131040).探测终止
WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated
完整的 FusionLog
=== 预绑定状态信息 === LOG: DisplayName = log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821(完全指定) LOG: Appbase = file:///F:/Cab ManagementSystem/CMS-Localized/CMS-Code/WebServices/CMSAPI/LOG:初始PrivatePath = F:Cab 管理SystemCMS-LocalizedCMS-CodeWebServicesCMSAPIin 调用程序集:paypal_base,版本=4.4.55.0,文化=中性,PublicKeyToken=b37401294aaf5617.=== LOG:此绑定在默认加载上下文中启动.日志:使用应用程序配置文件:F:Cab ManagementSystemCMS-LocalizedCMS-CodeWebServicesCMSAPIweb.config 日志:使用主机配置文件:C:UsersDellDocumentsIISExpressconfigaspnet.config 日志:使用机器配置文件来自C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config.日志:在应用程序配置文件中找到重定向:1.2.10.0重定向到 2.0.8.0.LOG:后政策参考:log4net,版本=2.0.8.0,文化=中性,PublicKeyToken=1b44e1d426115821 日志:正在尝试下载新 URLfile:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/TemporaryASP.NET 文件/vs/864fb64d/ad78f51e/log4net.DLL.日志:尝试下载新网址file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/TemporaryASP.NET 文件/vs/864fb64d/ad78f51e/log4net/log4net.DLL.日志:正在尝试下载新的 URL 文件:///F:/Cab ManagementSystem/CMS-Localized/CMS-Code/WebServices/CMSAPI/bin/log4net.DLL.警告:比较程序集名称导致不匹配:PUBLIC KEY TOKENERR: 未能完成程序集的设置 (hr = 0x80131040).探测终止.
=== Pre-bind state information === LOG: DisplayName = log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821 (Fully-specified) LOG: Appbase = file:///F:/Cab Management System/CMS-Localized/CMS-Code/WebServices/CMSAPI/ LOG: Initial PrivatePath = F:Cab Management SystemCMS-LocalizedCMS-CodeWebServicesCMSAPIin Calling assembly : paypal_base, Version=4.4.55.0, Culture=neutral, PublicKeyToken=b37401294aaf5617. === LOG: This bind starts in default load context. LOG: Using application configuration file: F:Cab Management SystemCMS-LocalizedCMS-CodeWebServicesCMSAPIweb.config LOG: Using host configuration file: C:UsersDellDocumentsIISExpressconfigaspnet.config LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config. LOG: Redirect found in application configuration file: 1.2.10.0 redirected to 2.0.8.0. LOG: Post-policy reference: log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=1b44e1d426115821 LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/864fb64d/ad78f51e/log4net.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/864fb64d/ad78f51e/log4net/log4net.DLL. LOG: Attempting download of new URL file:///F:/Cab Management System/CMS-Localized/CMS-Code/WebServices/CMSAPI/bin/log4net.DLL. WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY TOKEN ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
建议
我是否需要将两个 .dll 都放在/bin 文件夹中,
do I need to put both .dll in the /bin folder,
堆栈跟踪
在 com.paypal.sdk.profiles.BaseAPIProfile..ctor() 在com.paypal.sdk.profiles.ProfileFactory.createSignatureAPIProfile()
在 PayPalLibrary.PayPalPayment.SetPaymentProfile(String rsUserName,字符串 rsPassword、字符串 rsSignature、字符串 rsEnviroment、字符串rsIpAddress) 在 F:pathClassesPayPalPayment.cs:line 34 atAPI.ServiceBLL.DoCreditCardPayment(String txtNameOnCard, StringddlExpiryMonth,字符串 ddlExpiryYear,字符串 txtCardNo,字符串 txtCv2,字符串数量,String&付款服务类型)中F:PathServiceBLL.cs:line 2907
at com.paypal.sdk.profiles.BaseAPIProfile..ctor() at com.paypal.sdk.profiles.ProfileFactory.createSignatureAPIProfile()
at PayPalLibrary.PayPalPayment.SetPaymentProfile(String rsUserName, String rsPassword, String rsSignature, String rsEnviroment, String rsIpAddress) in F:pathClassesPayPalPayment.cs:line 34 at API.ServiceBLL.DoCreditCardPayment(String txtNameOnCard, String ddlExpiryMonth, String ddlExpiryYear, String txtCardNo, String txtCv2, String amount, String& paymentServiceType) in F:PathServiceBLL.cs:line 2907
更新
根据Ciprian Lipan在评论中的建议,我在.csproj
中发现了这个条目,其中PublicKeyToken
与我的web.config
不同我复制了这个令牌并在配置中替换,只有异常消息,内部异常消失了.下面是 .csproj 中的条目
after the suggestion of Ciprian Lipan in comments, I found this entry in .csproj
in which PublicKeyToken
was different from my web.config
I copied this token and replaced in config and got only exception message, inner exception gone. bellow is entry in .csproj
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<HintPath>packageslog4net.2.0.8lib
et45-fulllog4net.dll</HintPath>
<Private>True</Private>
</Reference>
例外
Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=**1b44e1d426115821**' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
但是我用 .csproj 中的新令牌更改了配置中的令牌
however I chnaged the token in config with new one found in .csproj
FusionLog
=== 预绑定状态信息 === LOG: DisplayName = log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821(完全指定) LOG: Appbase = file:///F:/Path/API/LOG: InitialPrivatePath = F:pathAPIin 调用程序集:paypal_base,版本=4.4.55.0,文化=中性,PublicKeyToken=b37401294aaf5617.=== LOG:此绑定在默认加载上下文中启动.LOG:使用应用程序配置文件:F:pathAPIweb.config LOG:使用主机配置文件:C:UsersmeDocumentsIISExpressconfigaspnet.config 日志:使用机器配置文件来自C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config.LOG:后政策参考:log4net,版本=1.2.10.0,文化=中性,PublicKeyToken=1b44e1d426115821 日志:正在尝试下载新网址file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/TemporaryASP.NET 文件/vs/864fb64d/ad78f51e/log4net.DLL.日志:尝试下载新网址file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/TemporaryASP.NET 文件/vs/864fb64d/ad78f51e/log4net/log4net.DLL.日志:正在尝试下载新的 URL 文件:///F:/path/API/bin/log4net.DLL.警告:比较程序集名称导致不匹配:主要版本ERR: 未能完成程序集的设置 (hr = 0x80131040).探测终止.
=== Pre-bind state information === LOG: DisplayName = log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821 (Fully-specified) LOG: Appbase = file:///F:/Path/API/ LOG: Initial PrivatePath = F:pathAPIin Calling assembly : paypal_base, Version=4.4.55.0, Culture=neutral, PublicKeyToken=b37401294aaf5617. === LOG: This bind starts in default load context. LOG: Using application configuration file: F:pathAPIweb.config LOG: Using host configuration file: C:UsersmeDocumentsIISExpressconfigaspnet.config LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config. LOG: Post-policy reference: log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821 LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/864fb64d/ad78f51e/log4net.DLL. LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/864fb64d/ad78f51e/log4net/log4net.DLL. LOG: Attempting download of new URL file:///F:/path/API/bin/log4net.DLL. WRN: Comparing the assembly name resulted in the mismatch: Major Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
推荐答案
Apache 决定更改他们的公钥,arg!类似帖子中有一个解决方案.
Apache decided to change their public key, arg! There is a solution in a similar post here.
或者您可以使用旧的公钥令牌恢复对旧的 1.2.10.0 版本的引用.nuget log4net 1.2.10.0
Or you could revert your reference to the older 1.2.10.0 version with the old public key token. nuget log4net 1.2.10.0
这篇关于无法加载文件或程序集“log4net,版本=2.0.8.0,文化=中性,PublicKeyToken=1b44e1d426115821"或其依赖项之一的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!