代码之家  ›  专栏  ›  技术社区  ›  James

无法加载程序集问题

  •  3
  • James  · 技术社区  · 8 年前

    我收到以下问题

    Could not load file or assembly 'NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
    

    === Pre-bind state information ===
    LOG: DisplayName = NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c
    (Fully-specified)
    LOG: Appbase = file:///C:/MyProj/XX.XXX.TempProj/
    LOG: Initial PrivatePath = C:\MyProj\XX.XXX.TempProj\bin
     Calling assembly : MyProj.CallingLayer, Version=1.2.1.1, Culture=neutral, PublicKeyToken=57732cb8f5e77948.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\MyProj\XX.XXX.TempProj\web.config
    LOG: Using host configuration file: \\corp.corpcommon.com\users\EXXXX\MY 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: NLog, Version=2.0.1.0, Culture=neutral, PublicKeyToken=5120e14c03d0593c
    LOG: Attempting download of new URL file:///C:/Users/EXXXX/AppData/Local/Temp/Temporary ASP.NET Files/vs/39ab25b3/cbea207a/NLog.DLL.
    LOG: Attempting download of new URL file:///C:/Users/EXXXX/AppData/Local/Temp/Temporary ASP.NET Files/vs/39ab25b3/cbea207a/NLog/NLog.DLL.
    LOG: Attempting download of new URL file:///C:/MyProj/XX.XXX.TempProj/bin/NLog.DLL.
    WRN: Comparing the assembly name resulted in the mismatch: Major Version
    ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
    

    我尝试使用nuget安装和卸载Nlog,但没有帮助。我试图改变网络。类似配置

    <dependentAssembly>
        <assemblyIdentity name="NLog" publicKeyToken="5120e14c03d0593c" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
    

    我正在使用Nlog 4.0版

    1 回复  |  直到 8 年前
        1
  •  2
  •   Evk    8 年前

    正如您的错误消息所说,您在项目中使用的一些dll是根据NLOG版本编译的 2.0.1.0 . 您的应用程序似乎正在使用NLOG版本4.0.0.0。您正确地尝试使用绑定重定向,但绑定重定向表示“重定向0.0.0.0和0.0.0之间的程序集NLOG的所有版本 到版本4.0.0.0。版本2.0.1.0大于2.0.0.0,因此不会重定向。例如,您可以参考这个问题来了解有关绑定重定向的更多信息: Assembly Binding redirect: How and Why? .