BadImageFormatException was unhandled

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John A Grandy

    BadImageFormatException was unhandled

    VS2005 ( all updates ) on XP ( all updates )

    I have a solution with many projects and a substantial reference tree.

    I have a Windows Application project that will build but not run. It fails
    in Program.cs when it attempts to invoke the form class :

    Application.Run ( new Form1() );


    BadImageFormatE xception was unhandled

    Could not load file or assembly 'MyApi, Version=1.0.0.0 , Culture=neutral ,
    PublicKeyToken= null' or one of its dependencies. An attempt was made to load
    a program with an incorrect format.


    The strange thing is that other Windows Applications that contain a
    reference to the MyApi assembly run just fine.

    I clean and rebuild to no avail. Also, removing/adding ref does not help.

    What could be going on ?


  • =?Utf-8?B?QXR1bCBSYW5l?=

    #2
    RE: BadImageFormatE xception was unhandled



    "John A Grandy" wrote:
    VS2005 ( all updates ) on XP ( all updates )
    >
    I have a solution with many projects and a substantial reference tree.
    >
    I have a Windows Application project that will build but not run. It fails
    in Program.cs when it attempts to invoke the form class :
    >
    Application.Run ( new Form1() );
    >
    >
    BadImageFormatE xception was unhandled
    >
    Could not load file or assembly 'MyApi, Version=1.0.0.0 , Culture=neutral ,
    PublicKeyToken= null' or one of its dependencies. An attempt was made to load
    a program with an incorrect format.
    >
    >
    The strange thing is that other Windows Applications that contain a
    reference to the MyApi assembly run just fine.
    >
    I clean and rebuild to no avail. Also, removing/adding ref does not help.
    >
    What could be going on ?
    >
    >
    Hi john,
    I think the problem is in your image which is you trying to open, try to
    open different image file.

    Comment

    • John A Grandy

      #3
      Re: BadImageFormatE xception was unhandled

      No this has nothing to do with image ( .img ) files. I am not working with
      any images.


      "Atul Rane" <AtulRane@discu ssions.microsof t.comwrote in message
      news:F5CD6CDA-A98A-458A-8861-0A9330517F3E@mi crosoft.com...
      >
      >
      "John A Grandy" wrote:
      >
      >VS2005 ( all updates ) on XP ( all updates )
      >>
      >I have a solution with many projects and a substantial reference tree.
      >>
      >I have a Windows Application project that will build but not run. It
      >fails
      >in Program.cs when it attempts to invoke the form class :
      >>
      >Application.Ru n( new Form1() );
      >>
      >>
      >BadImageFormat Exception was unhandled
      >>
      >Could not load file or assembly 'MyApi, Version=1.0.0.0 , Culture=neutral ,
      >PublicKeyToken =null' or one of its dependencies. An attempt was made to
      >load
      >a program with an incorrect format.
      >>
      >>
      >The strange thing is that other Windows Applications that contain a
      >reference to the MyApi assembly run just fine.
      >>
      >I clean and rebuild to no avail. Also, removing/adding ref does not
      >help.
      >>
      >What could be going on ?
      >>
      >>
      >Hi john,
      I think the problem is in your image which is you trying to open, try to
      open different image file.

      Comment

      • jacky kwok

        #4
        Re: BadImageFormatE xception was unhandled

        John A Grandy wrote:
        No this has nothing to do with image ( .img ) files. I am not working with
        any images.
        >
        >
        "Atul Rane" <AtulRane@discu ssions.microsof t.comwrote in message
        news:F5CD6CDA-A98A-458A-8861-0A9330517F3E@mi crosoft.com...
        >>
        >"John A Grandy" wrote:
        >>
        >>VS2005 ( all updates ) on XP ( all updates )
        >>>
        >>I have a solution with many projects and a substantial reference tree.
        >>>
        >>I have a Windows Application project that will build but not run. It
        >>fails
        >>in Program.cs when it attempts to invoke the form class :
        >>>
        >>Application.R un( new Form1() );
        >>>
        >>>
        >>BadImageForma tException was unhandled
        >>>
        >>Could not load file or assembly 'MyApi, Version=1.0.0.0 , Culture=neutral ,
        >>PublicKeyToke n=null' or one of its dependencies. An attempt was made to
        >>load
        >>a program with an incorrect format.
        >>>
        >>>
        >>The strange thing is that other Windows Applications that contain a
        >>reference to the MyApi assembly run just fine.
        >>>
        >>I clean and rebuild to no avail. Also, removing/adding ref does not
        >>help.
        >>>
        >>What could be going on ?
        >>>
        >>>
        >>Hi john,
        >I think the problem is in your image which is you trying to open, try to
        >open different image file.
        >
        >

        In general, this exception happens when a dependent is not correct in
        the current OS platform.

        For example, in 64 bit OS, a dotnet2 app loads a native 32bit DLL. (64
        bit app cannot load 32 bit DLL).

        Since, no info about what is the platform the problem happens, cannot
        confirm is this case.

        Note about that, for dotnet2 app, the will run as 64 bit app in 64 bit
        OS, except the developer directly mark it is 32bit only. Otherwise, the
        64 bit main exe cannot load any 32bit DLL, include the DLL which uses
        managed C++ and it calls the win API, or other natvie C 32bit DLL.



        --
        Jacky Kwok
        jacky@alumni_DO T_cuhk_DOT_edu_ DOT_hk

        Comment

        Working...