16

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" />
Emily
  • 444
  • 1
  • 3
  • 12

7 Answers7

6

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">

neoscribe
  • 2,203
  • 1
  • 21
  • 18
  • 2
    log4net 1.2.10.0 from Apache has the public key token "1b44e1d426115821". The 1.2.10.0 version from SAP runtimes has the public key token "692fbea5521e1304". SAP provides both a 32-bit and 64-bit with the "692fbea5521e1304" token. So, it's not that there's a difference in 32-bit and 64-bit, but that the assemblies are signed completely differently. When resolving strongly named assemblies, the application can't find SAP's version on runtime binding. OP stated they changed the public token to match, but SAP's log4net != Apache's log4net of the same version. – Eliasar Jan 22 '20 at 16:38
2

Try adding this to your web.config. It basically tells the run-time that you are OK for it loading the same assembly for both version

  <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="log4net" publicKeyToken="692fbea5521e1304" culture="neutral" />
                <bindingRedirect oldVersion="0.0.0.0-1.2.10.0" newVersion="1.2.10.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>

You'll need to replace 1.2.10.0 with the version that you actually have in your bin folder.

kay.one
  • 7,622
  • 6
  • 55
  • 74
  • It seems like it would work, but it doesn't seem to redirect all assembly references. – Emily Jul 26 '12 at 18:48
  • @notkilroy can you explain a bit more? what do you mean it doesn't redirect all references? can you give me the updated error message? – kay.one Jul 27 '12 at 16:56
  • It's a could not load file or assembly log4net. The located assembly's manifest definition does not match the assembly reference. However, instead of the error pointing to code in my web.config, it now points to a line in an individual page. The line is: "" – Emily Jul 27 '12 at 19:23
1

If your machine is 64bit and you install Crystal Report 32bit version, then this error will haunt you like anything. In this case, all the required assemblies are properly registered in GAC but still, it says "unable to load log4net assembly..." The reason for this error is that you are trying to execute a 32bit application on a 64bit machine.

If you are implementing reporting on the server side the IIS will not allow executing this application. To resolve this you have to enable 32bit application in IIS.

Steps for this are:

  1. Go to the app pool on which you are running your application
  2. Right click and go to Advanced Settings
  3. Here find "Enable 32-Bit Applications" and set it to true
  4. Reset IIS (iisreset)
0

I had this problem in my code. One of the Projects that someone was using had Log4Net version conflicts. They were using 12.2.10 and I had 12.2.13. So to fix the problem I got rid of my reference and found their reference dll. I used that instead and it worked perfectly.

To find a reference Microsoft Visual Studio has a Browser feature. You can use that to get the dll. To find the dll you can click on your references in your project and the click the reference that you want to find. In this case Log4Net. It will show a list of dependencies, the other log4net should be near the selected Log4Net, and there should be a some text showing the location of the current selected dll reference. This is where you will find the reference.

Jackstine
  • 486
  • 4
  • 12
0

MSDOS

-- Create a virtual disk
subst t: C:\Windows\assembly

-- Delete log4net x64 assembly
del t:\GAC_64\log4net\1.2.10.0__692fbea5521e1304\log4net.dll

-- remove the virtual disk
subst t: /d
boubkhaled
  • 379
  • 5
  • 6
0

For your issue i recommend you to delete/remove this dll in refereneces and reinstall and Here is how to properly install Log4Net on VS 2013:

1) Making sure you turn on your nuget.org Package Sources for NuGet Packages Manager utility by: Rightclick Project (not solution) then select "Manague NUGet Packages ..." at bottom left select "Settings" then select "Package Manager" then select "Package Sources" under Available package sources select "nuget.org" also check both "Machine-wid package sources" the click "OK"

2) It will take you to Manage NUGet Packages then select "Online" on the left pane then search for "log4net" it is ported from apache log4j then install it. Done you will find it installed under References in your project

I also attached screenshots.

enjoy!

enter image description here

enter image description here

Dung
  • 19,199
  • 9
  • 59
  • 54
0

I downloaded this x86 version and the problem is solved

https://downloads.i-theses.com/index.php?option=com_downloads&task=downloads&groupid=9&id=100

mesutpiskin
  • 1,771
  • 2
  • 26
  • 30