Failed to load file or assembly "log4net" or one of its dependencies

I am trying to create a crystal report and I am new to this area. I created a crystal report for this training post , but it does not seem to work.

My mistake:

Failed to load file or assembly 'log4net' or one of its dependencies. An attempt was made to download a program with the wrong format.

Description: An unhandled exception occurred during the execution of the current web request. View the stack trace for more information about the error and its occurrence in the code.

Exception Details: System.BadImageFormatException: Failed to load file or assembly 'log4net' or one of its dependencies. An attempt was made to download a program with the wrong format.

Source Error:

An unhandled exception was thrown during the execution of the current web request. Information about the origin and location of the exception can be identified using the exception stack trace below.

Assembly load trace: The following information may be useful in determining why the log4net assembly cannot be loaded.

+4
source share
2 answers

BadFormatImageException is an error that you get when your program is compiled for 32-bit architecture and tries to load a 64-bit library or vice versa. From this error, you are referencing log4net (a well-known log library).
First , check which processor you are creating for your application (x86, x64, AnyCPU)
Second , check the bit size of log4net (you need to specify the same bitt of your applications)
Third , check that IIS is running. (if x64 and your application are 32, set the "Enable 32-bit applications" parameter to true in the advanced settings section of the application pool)

+7
source

"An attempt was made to download a program with the wrong format." maybe because some of your dlls are 32 bits and some of them are 64 bits. Another reason may be that your application server is configured for 64-bit and 32-bit DLLs (or vice versa).

I would first check the IIS settings (this depends on the version of IIS you are using) and then check if the dlls are compiled to 32 bits or 64 bits (from myproject settings).

+1
source

Source: https://habr.com/ru/post/1401701/


All Articles