Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error: Could not load log4net assembly

I am looking to solve this error:

Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The system cannot find the file specified." This error is located in the web.config file.

When I copy log4net.dll to the bin directory of my webapp, I get a

Could not load file or assembly 'log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=692fbea5521e1304' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.

This error also occurs in the web.config file.

It's easy enough to change the version and the public key token to match the file so that the assembly loads correctly. When I do that, my website runs perfectly, except for when a reportViewer object is initialized. Then it throws the original error at the reportViewer tag, not the web.config.

My hypothesis is that if I install the requested version of log4net.dll, my problems will be solved. But I have no clue which file that it, or where to find it. I've checked the obvious by downloading log4net 1.2.10 and trying out every dll in the download.

I should mention that the website runs without issues on my development machine, but not when published to my server.

I'm running an asp.net website, .NET 4.0, IIS 7, on a Server 2008 R2 OS. I've installed Crystal Reports 13.0.1 for 64bit (my machine is 64bit).

How can I resolve this issue?

EDIT: In response to @Kevian's answer, I have made the change to my web.config file. I still get the error where the manifest definition doesn't match the assembly reference. The code that throws this error is:

Line 33:     <CR:CrystalReportViewer ID="CrystalReportViewer1" runat="server"   AutoDataBind="true"
Line 34:         BestFitPage="True" ToolPanelView="None" />
like image 811
Emily Avatar asked Jul 26 '12 16:07

Emily


1 Answers

There are a couple of issues at play here that are resolvable:

  1. The public key token for the 32bit version of log4net.dll clashes with the one used by Crystal Reports. To verify if you have this problem, do a search for "692fbea5521e1304" in all of your .csproj files - if you see references to CrystalDecisions AND log4net you have this problem.
  2. The 32bit version of log4net.dll clashes with dlls that are compiled for 64-bit or AnyCPU architecture. If you have this problem, you will find the references that look like below. You can verify the problem by reconfiguring your application pool to run as 32bit and checking to see if the app runs - if it does, you have this problem.
<Reference Include="log4net, Version=1.2.10.0, Culture=neutral, 

PublicKeyToken=692fbea5521e1304, processorArchitecture=x86" >

The Fix that worked for us in 64-bit was to get the latest log4net.dll which actually has a new PublicKeyToken, replace the log4net.dll in your 3rd party bin folder, AND change all of the log4net.dll references to look like so:

<Reference Include="log4net, Version=1.2.10.0, Culture=neutral,

PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">

like image 66
neoscribe Avatar answered Oct 08 '22 23:10

neoscribe