Posted on 2012-09-05
Last Modified: 2012-09-07
When I run my application in Visual Studio in Debug mode, it runs fine. When I run it in Release mode,  I get BadimageFormatException: Could not load file or assembly.
Where should I be looking for difference in Debug/Release loading?
Question by:allelopath
    LVL 26

    Assisted Solution

    by:Alan Warren
    Are you running 64 bit on both your dev server and your production server?

    LVL 13

    Assisted Solution

    by:Naman Goel
    Project propertiesGoto Project properties and all the dependent project properties --> Build tab select Release from configuration select Platform target as Any CPU
    LVL 1

    Author Comment

    Thanks but it looks like all projects in the solution were already set to Any CPU
    LVL 13

    Accepted Solution

    check each and every dll with coreflag tool

    Please use tool CorFlags.exe to view the header of the DLL to identify
    which target platform it is compiled to. Following are the instructions:
    1. Open Visual Studio command prompt.
    2. Type "CorFlags.exe <Assembly File Path>".
    3. You will see its output like this:
    Version : v2.0.50727
    CLR Header : 2.5
    PE : PE32
    CorFlags : 11
    ILONLY : 1
    32BIT : 1
    Signed : 1
    4. The PE and 32BIT flags can be used to determine the type of the
    assembly, please look up the following table:
    anycpu: PE = PE32 and 32BIT = 0
    x86: PE = PE32 and 32BIT = 1
    64-bit: PE = PE32+ and 32BIT = 0

    For more information, please refer to following links:

    Moving from 32-bit to 64-bit application development on .NET Framework:

    and make sure that all assemblies used in same format
    LVL 23

    Assisted Solution

    by:Roopesh Reddy

    Try setting the Platform Target to x86 and make sure you set this configuration for Release!

    VS Properties
    Hope it helps u...

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project ( automates most of the tasks discussed in this article. You can even fin…
    Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (…
    THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now