3

I am getting following issue

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)

More information

=== 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.

I tried to install and uninstall Nlog using nuget but its not helping. i tried to change web.config like

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

I am using Nlog Version 4.0

James
  • 1,827
  • 5
  • 39
  • 69
  • 1
    Your redirect redirects versions up to 2.0.0.0 but your error indicates some assembly wants 2.0.1.0. So try to redirect all versions up to that one (or better just up to 4.0.0.0). – Evk Nov 09 '17 at 08:05
  • @Evk great thanks.. Please put it as answer so i cna Accept. Also if possible explain bit on bindingredirect or i can Google it – James Nov 09 '17 at 08:39

1 Answers1

2

As your error message says - some dll which you use in your project was compiled against NLOG version 2.0.1.0. Your application seems to be using NLOG version 4.0.0.0. You correctly trying to use binding redirect, but your binding redirect says "redirect all versions of assembly NLOG between 0.0.0.0 and 2.0.0.0 to version 4.0.0.0. Version 2.0.1.0 is bigger than 2.0.0.0 so it's not redirected. You can refer to this question for example to learn a bit more about binding redirects: Assembly Binding redirect: How and Why?.

Evk
  • 98,527
  • 8
  • 141
  • 191