Home All Groups Group Topic Archive Search About

BadImageFormatException on framework 64 bit

Author
6 Jun 2006 1:11 PM
Rudy
My application uses a win32 DLL (unmanaged code) and it works well with .net
framework 32 bit. Now I'm testing it with .net framework 64 bit on a pc with
windows XP 64 bit and as soon as the application start I get this error when
the program load the win32 dll: System.BadImageFormatException: An attempt
was made to load a program with an incorrect format. (Exception from HRESULT:
0x8007000B)
I read win 32 applications work on windows XP 64 bit, so why this exception?
Author
7 Jun 2006 1:39 AM
jacky kwok
Rudy wrote:
> My application uses a win32 DLL (unmanaged code) and it works well with .net
> framework 32 bit. Now I'm testing it with .net framework 64 bit on a pc with
> windows XP 64 bit and as soon as the application start I get this error when
> the program load the win32 dll: System.BadImageFormatException: An attempt
> was made to load a program with an incorrect format. (Exception from HRESULT:
> 0x8007000B)
> I read win 32 applications work on windows XP 64 bit, so why this exception?
>

Is your application a Dotnet2.0 application?

Do you install the 64bit dotent2.0 framework in your 64 machine XP?

If both yes, your application will run in native 64bit mode and it
cannot load any 32 bit native dll (non-dotnet dll).

You can check your application in the task manager in "Processes" tab in
64 OS. If it has no a mark "*32", it is running in 64 bit mode.

If the application is developed yourself, you can set it in the
development tools (e.g. VS2005) to mark it always running in 32 bit
mode. Then, your application can use the 32 bit dll no problem.





--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk
Are all your drivers up to date? click for free checkup

Author
7 Jun 2006 9:23 AM
Rudy
> You can check your application in the task manager in "Processes" tab in
> 64 OS. If it has no a mark "*32", it is running in 64 bit mode.
> If the application is developed yourself, you can set it in the
> development tools (e.g. VS2005) to mark it always running in 32 bit
> mode. Then, your application can use the 32 bit dll no problem.

Yes you are right, it is running in 64 bit mode.
But if I set it to run in 32 bit mode then all managed and unmanaged code
run in 32 bit mode? In other words can I take advantage from 64 bit system or
not?
Thanks!!!
Author
8 Jun 2006 1:28 AM
jacky kwok
Rudy wrote:
>> You can check your application in the task manager in "Processes" tab in
>> 64 OS. If it has no a mark "*32", it is running in 64 bit mode.
>> If the application is developed yourself, you can set it in the
>> development tools (e.g. VS2005) to mark it always running in 32 bit
>> mode. Then, your application can use the 32 bit dll no problem.
>
> Yes you are right, it is running in 64 bit mode.
> But if I set it to run in 32 bit mode then all managed and unmanaged code
> run in 32 bit mode? In other words can I take advantage from 64 bit system or
> not?
> Thanks!!!


In my opinion, it is dependent on your actual case.

If your 64bit OS just run only one application and the application is
32bit application, it will not take advantage from 64 bit system.

However, in most case, there are many applications running in one
computer. Hence, overall the system still can take some advantage, e.g.
the system can use more physical memory (if the computer have so much
memory).

Of cause, the best solution is to convert the 32 bit DLL to 64 bit DLL.


--
Jacky Kwok
jacky@alumni_DOT_cuhk_DOT_edu_DOT_hk
jacky@compose_DOT_com_DOT_hk

Bookmark and Share