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

tri*_*ati 12 .net c# asp.net log4net .net-assembly

我找到了几个涉及这个问题的线索,但没有一个解决了我的问题.

我以前log4net version 1.2.10.0在我的ASP.NET服务中使用过.我已将其更新为当前版本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>
Run Code Online (Sandbox Code Playgroud)

我也对这些消息内部异常感到困惑 :((System.IO.FileLoadException)ex.InnerException.InnerException).Message

无法加载文件或程序集'log4net,Version = 1.2.10.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)

例外消息:

无法加载文件或程序集'log4net,Version = 2.0.8.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(HRESULT异常:0x80131040)

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

警告:比较程序集名称导致不匹配:PUBLIC KEY TOKEN ERR:无法完成程序集的设置(hr = 0x80131040).探测终止

完整的FusionLog

===预绑定状态信息===日志:DisplayName = log4net,Version = 1.2.10.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821(完全指定)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,Culture =中立,PublicKeyToken = b37401294aaf5617.===日志:此绑定在默认加载上下文中启动.日志:使用应用程序配置文件:F:\ Cab Management System\CMS-Localized\CMS-Code\WebServices\CMSAPI\web.config日志:使用主机配置文件:C:\ Users\Dell\Documents\IISExpress\config\aspnet .config日志:使用C:\ Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config中的计算机配置文件.日志:在应用程序配置文件中找到重定向:1.2.10.0重定向到2.0.8.0.日志:后策略引用:log4net,Version = 2.0.8.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821日志:尝试下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/864fb64d/ad78f51e/log4net.DLL.日志:尝试下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/864fb64d/ad78f51e/log4net/log4net.DLL.日志:尝试下载新的URL文件:/// F:/ Cab Management System/CMS-Localized/CMS-Code/WebServices/CMSAPI/bin/log4net.DLL.警告:比较程序集名称导致不匹配:PUBLIC KEY TOKEN ERR:无法完成程序集的设置(hr = 0x80131040).探测终止.

建议

我需要将.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 )F:\ path\Classes\PayPalPayment.cs:第34行,位于F:\ Path\ServiceBLL中的API.ServiceBLL.DoCreditCardPayment(String txtNameOnCard,String ddlExpiryMonth,String ddlExpiryYear,String txtCardNo,String txtCv2,String amount,String&paymentServiceType) .cs:第2907行

更新

西普里安利攀的意见建议后,我发现在这个条目.csproj中,PublicKeyToken是从我的不同web.config我复制此令牌,并在配置更换,只拿到了异常消息,内部异常了.bellow是进入.csproj的

<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
      <HintPath>packages\log4net.2.0.8\lib\net45-full\log4net.dll</HintPath>
      <Private>True</Private>
</Reference>
Run Code Online (Sandbox Code Playgroud)

例外

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)
Run Code Online (Sandbox Code Playgroud)

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

FusionLog

===预绑定状态信息=== LOG:DisplayName = log4net,Version = 1.2.10.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821(完全指定)LOG:Appbase = file:/// F:/ Path/API/LOG:Initial PrivatePath = F:\ path\API\bin调用程序集:paypal_base,Version = 4.4.55.0,Culture = neutral,PublicKeyToken = b37401294aaf5617.===日志:此绑定在默认加载上下文中启动.日志:使用应用程序配置文件:F:\ path\API\web.config日志:使用主机配置文件:C:\ Users\me\Documents\IISExpress\config\aspnet.config日志:使用C:\中的机器配置文件的Windows\Microsoft.NET \框架\ v4.0.30319\CONFIG\machine.config中.日志:后策略引用:log4net,Version = 1.2.10.0,Culture = neutral,PublicKeyToken = 1b44e1d426115821日志:尝试下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/864fb64d/ad78f51e/log4net.DLL.日志:尝试下载新的URL文件:/// C:/Windows/Microsoft.NET/Framework/v4.0.30319/Temporary ASP.NET Files/vs/864fb64d/ad78f51e/log4net/log4net.DLL.日志:尝试下载新的URL文件:/// F:/path/API/bin/log4net.DLL.警告:比较程序集名称导致不匹配:主要版本 错误:无法完成程序集的设置(hr = 0x80131040).探测终止.

Twi*_*tem 5

Apache决定更改其公共密钥arg!在类似的帖子中有一个解决方案。

或者,您可以使用旧的公共密钥令牌将引用恢复为旧的1.2.10.0版本。nuget log4net 1.2.10.0