Could not load file or assembly ‘log4net’ or one of its dependencies

asp.netcrystal-reportslog4netvisual studio 2010

I am trying to create a crystal report and I am new to that field. I have created a crystal report from this tutorial post but it does not seems to work.

My error is :

Could not load file or assembly 'log4net' or one of its dependencies. An attempt was made to load a program with an incorrect format.

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.BadImageFormatException: Could not load file or assembly 'log4net' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error:

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

Assembly Load Trace: The following information can be helpful to determine why the assembly 'log4net' could not be loaded.

Best Answer

BadFormatImageException is the error that you receive when your program is compiled for a 32bit architecture and will try to load a 64bit library or viceversa. From the error, you have a reference to log4net (a well known log library).
First, check for what kind of CPU you are creating your application (x86, x64, AnyCPU)
Second, check the bitness of log4net (You should reference the same bitness of your apps)
Third, check on what OS IIS is running. (if is x64 and your app 32, set 'Enable 32-bit Applications' to true in the advanced settings section of the application pool)