Skip to Content
avatar image
Former Member

Could not load file or assembly 'log4net' or one of its dependencies. An at

Hi guys,

Yesterday I downloaded the CR release for VS2010. Before this I was using the Beta (and later Beta2) version. Both worked fine. I first uninstalled the beta version, next I installed the release version. No problems with installing. But now I'm trying to use CR. I get the error:

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

I noticed that it has something to do with the runtime enviroment. If I set the project's platform target to x86, it works fine. Turning it back to 'any CPU' or x64, it results in that error. (I'm using w7 x64).

I did install the the x64 runtime (CRRuntime_64bit_13_0.msi, also asked at the end of the installation).

Any ideas how to solve this?

Why is CR using log4net anyway?

Best,

Danny

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Dec 12, 2010 at 10:20 PM

    I am getting the same error message (log4net), so you may be interested in my scenario, which remains unresolved.

    My development machine running VS2010 and CR 13.0.2000 (release) is W7 x86, and the web server I deploy to is Server 2008 R2 x64. I can also deploy to XP x86 as a test server. The web application targets .NET 4 and all libraries which form part of the solution which reference CR, reference the same version 13.0.2000. The web site uses a 2010 Web Deployment project and web setup project to compile the msi.

    When I deploy to the XP box (setup targets x86), there are no issues and the site opens.

    When I deploy to the R2 box (setup targets x64), I get the error "Could not load file or assembly 'log4net'..."

    When I deploy to the R2 box (setup targets x86), I get the same error.

    In the directory "C:\Windows\assembly", there is only one instance of log4net.dll.

    Is this problem simply that I cannot deploy from x86 to x64 when CR is referenced?

    Robert

    Add comment
    10|10000 characters needed characters exceeded

  • Nov 30, 2010 at 04:32 PM

    Is this a local install, or are you using some sort of a remote connection?

    Are you getting the error at build time or at runtime? (Reference assemblies is always build-time, GAC is always runtime)

    Look in the GAC. Do you see Log4Net.dll? There should be two - one for 32 bit and one for 64 bit OS (same version though).

    Ludek

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 29, 2010 at 10:46 PM

    I took out a paid support case with SAP to resolve this issue, and it is resolved after many emails and time spent in investigation. Here is the fix for VS2010 websites:

    - In the Web setup project right-click the primary output and select u201CExclude filteru201D, then u201CAdd filteru201D

    - add u201Clog4net.dllu201D and save the dialog

    - build the project

    For VS2010 WinForm projects (I haven't tested this):

    - open the winform project properties

    - on the Build tab select Application files

    - exclude log4net.dll

    Robert

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 30, 2010 at 01:40 AM

    Thank you Robert for your patience and posting the solution.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 06, 2011 at 07:49 PM

    Hi, I got same error message. my situation is:

    1. a web site developed with visual studio 2010 (local dev environment is 32-bit)

    2. references to crystal report 13 (for vs 2010) (all assemblies are copied to bin folder)

    3. deploy the app to ii7 (windows 2008 server) WITHOUT crystal report installed.

    in my dev enviornment, it's working fine when crystal report 13 installed in gac, and gets same error when I removed crystal report 13 (still keep assemblied in bin folder)

    I tried following ways people provieded in the blog:

    1. enable 32-bit app for application pool (on IIS)

    2. targeting 64-bit when building

    3. add <starup ....> in web.config file

    but none of them helped.

    please help!!!!

    MAX

    Add comment
    10|10000 characters needed characters exceeded