common.logging - Redirect found in application configuration file
Asked Answered
S

2

5

I added common.logging.log4net to my visual studio 2012 solution via nuget.

common.logging.log4net ver. - 2.0.1 common.logging ver. - 2.0.0 log4net - ver. 1.2.10

When I build/run it locally, I see the following exception via browser:

Could not load file or assembly 'Common.Logging' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.FileLoadException: Could not load file or assembly 'Common.Logging' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Stack Trace:

[FileLoadException: Could not load file or assembly 'Common.Logging' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

It is looking for Common.Logging Version=2.1.1.0, which it can't find because it is not loaded. Now when I debug the app, I see the following exception, which is a bit different:

LOG: This bind starts in default load context.

LOG: Using application configuration file: C:\Workspaces\FTM\Apps\TM\TM.Web\web.config

LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG: Policy not being applied to reference at this time (private, custom, partial, or location-based assembly bind).

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e97e0952/56ab271f/Common.Logging.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e97e0952/56ab271f/Common.Logging/Common.Logging.DLL.

LOG: Attempting download of new URL file:///C:/Workspaces/FTM/Apps/TM/TM.Web/bin/Common.Logging.DLL.

LOG: Using application configuration file: C:\Workspaces\FTM\Apps\TM\TM.Web\web.config

LOG: Using host configuration file: C:\Windows\Microsoft.NET\Framework64\v4.0.30319\aspnet.config

LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.

LOG: Redirect found in application configuration file: 2.0.0.0 redirected to 2.1.1.0.

LOG: Post-policy reference: Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e97e0952/56ab271f/Common.Logging.DLL.

LOG: Attempting download of new URL file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/Temporary ASP.NET Files/root/e97e0952/56ab271f/Common.Logging/Common.Logging.DLL.

LOG: Attempting download of new URL file:///C:/Workspaces/FTM/Apps/TM/TM.Web/bin/Common.Logging.DLL. WRN: Comparing the assembly name resulted in the mismatch: Minor Version ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

Stack Trace:

[FileLoadException: Could not load file or assembly 'Common.Logging' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]

[FileLoadException: Could not load file or assembly 'Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)] System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +0
System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) +210
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean forIntrospection) +242
System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +17 System.Reflection.Assembly.Load(String assemblyString) +35
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +122

[ConfigurationErrorsException: Could not load file or assembly 'Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +12761078
System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +503 System.Web.Configuration.AssemblyInfo.get_AssemblyInternal() +142 System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +334
System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath) +203
System.Web.Compilation.BuildManager.ExecutePreAppStart() +152
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): Could not load file or assembly 'Common.Logging, Version=2.1.1.0, Culture=neutral, PublicKeyToken=af08829b84f0328e' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12881540 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12722601

Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.17929

Not sure why its trying to redirect to 2.1.1.0 (according to the logs)

Tom

Shooin answered 28/9, 2012 at 16:31 Comment(1)
maybe this post can help you: #2237272Lecia
Z
8

this line I think hints at the issue:

LOG: Redirect found in application configuration file: 2.0.0.0 redirected to 2.1.1.0.

Check your application config file (app.config) for an assembly redirect that is telling it to attempt to load version 2.1.1.0 anytime something requests version 2.0.0.0.

Zebu answered 5/6, 2013 at 3:46 Comment(0)
P
0

I had to run fuslogvw (fusion log viewer) to determine how a project was working and using NewtonSoft 9.0 even though there was a reference to NewtonSoft 6.0.

Another project with the same library dependency was crashing but saying it needed version 6.0 even though I couldn't find any place that 6.0 was being referenced.

It was driving me crazy.

I set the Fusion Log Viewer settings like the following so it would log all library binds: fusion log view settings

I fired up the project and watched fusion log viewer watched.

I saw the following:

fusion log viewer shows newtonsoft 6.0

I opened that log and saw the following:

LOG: This bind starts in default load context. LOG: Using application configuration file: [[ my app config ]] LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.

LOG: Redirect found in application configuration file: 6.0.0.0 redirected to 9.0.0.0. LOG: Post-policy reference: Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed LOG: GAC Lookup was unsuccessful.

I looked in app.config of the project that successfully runs (which binded to version 6. and redirected properly to 9) and I saw the following XML.

<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>
    </assemblyBinding>
  </runtime>

Very confusing. But, I added that snippet into the project that was crashing because it couldn't find version 6 and the app started running perfectly.

Oy!

Fusion Log Viewer

If you want to try running Fusion log viewer start a Visual Studio Command prompt -- Choose x64 Cross Tools Command Prompt and you'll be able to type:

/> fuslogvw <ENTER>

Oh, you have to have admin rights to be able to configure it. Good luck.

Pedestal answered 6/3, 2023 at 22:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.