c# – 无法加载文件或程序集’log4net,Version = 2.0.8.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821’或其依赖项之一

前端之家收集整理的这篇文章主要介绍了c# – 无法加载文件或程序集’log4net,Version = 2.0.8.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821’或其依赖项之一前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我发现有几个线程涉及这个问题,但没有一个解决了我的问题.

我之前在ASP.NET服务中使用过log4net 1.2.10.0版.我已将其更新为当前版本的log4net v2.0.8.0,由于某些第三方库,我还在web.config中添加了以下行以支持/重定向旧版本.

<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

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)

例外消息:

Could not load file or assembly ‘log4net,Version=2.0.8.0,PublicKeyToken=1b44e1d426115821′ or one of its
dependencies. The located assembly’s manifest definition does not
match the assembly reference. (Exception from HRESULT: 0x80131040)

可能以下几行指向FusionLog中的问题

WRN: Comparing the assembly name resulted in the mismatch: PUBLIC KEY
TOKEN ERR: Failed to complete setup of assembly (hr = 0x80131040).
Probing terminated

完整的FusionLog

=== 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
System\CMS-Localized\CMS-Code\WebServices\CMSAPI\bin Calling assembly
: paypal_base,Version=4.4.55.0,
PublicKeyToken=b37401294aaf5617.
=== LOG: This bind starts in default load context. LOG: Using application configuration file: F:\Cab Management
System\CMS-Localized\CMS-Code\WebServices\CMSAPI\web.config LOG: Using
host configuration file:
C:\Users\Dell\Documents\IISExpress\config\aspnet.config LOG: Using
machine configuration file from
C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.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,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文件夹中,

堆栈痕迹

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:\path\Classes\PayPalPayment.cs:line 34 at
API.ServiceBLL.DoCreditCardPayment(String txtNameOnCard,String
ddlExpiryMonth,String ddlExpiryYear,String txtCardNo,String txtCv2,
String amount,String& paymentServiceType) in
F:\Path\ServiceBLL.cs:line 2907

更新

在Ciprian Lipan的评论建议之后,我在.csproj中找到了这个条目,其中PublicKeyToken与我的web.config不同我复制了这个标记并在config中替换并且只获得了异常消息,内部异常消失了. bellow是进入.csproj的

<Reference Include="log4net,Version=2.0.8.0,PublicKeyToken=669e0ddf0bb1aa2a,processorArchitecture=MSIL">
      <HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
      <Private>True</Private>
</Reference>

例外

Could not load file or assembly 'log4net,PublicKeyToken=**1b44e1d426115821**' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

但是我在配置中使用.csproj中找到的新令牌

FusionLog

=== Pre-bind state information === LOG: DisplayName = log4net,PublicKeyToken=1b44e1d426115821
(Fully-specified) LOG: Appbase = file:///F:/Path/API/ LOG: Initial
PrivatePath = F:\path\API\bin Calling assembly
: paypal_base,
PublicKeyToken=b37401294aaf5617.
=== LOG: This bind starts in default load context. LOG: Using application configuration file: F:\path\API\web.config LOG: Using
host configuration file:
C:\Users\me\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: log4net,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!在 similar post here中有一个解决方案.

或者,您可以使用旧的公钥令牌恢复对旧版1.2.10.0的引用. nuget log4net 1.2.10.0

原文链接:https://www.f2er.com/csharp/100110.html

猜你在找的C#相关文章