posted by: Ralf Rottmann | posted @ Monday, June 25, 2007 9:34 AM | View blog reactions

Existing .NET applications might run into an issue with Win32 Dynamic Link Libraries that might not be executed in a 32-bit process in a .NET x64 environment.

You might see an exception as follows:

System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)

One possible solution:

  • If a full recompile of the solution is feasible Visual Studio 2005 allows to change the Platform Target from AnyCPU to x86 under the Build Settings.

  • If there is no chance to recompile the entire solution (e.g. third party components' sources are not available) the .NET Framework SDK tool corflags.exe allows users to change the CLR header in a way to enforce the x86 compiler switch:

    corflags /32BIT+ /force application.exe

    In case the assembly uses a strong name its hash has changed due to the above header change and requires to be signed again (which means you do need its private key and the sn.exe SDK tool):

    sn -R application.exe application.snk

  • Once the above steps have been executed a strongly named assembly will be prepared to be executed in a 64-bit environment even when using Win32-DLLs.

 

comments
No comments posted yet.
post your comment
Title *
Name *
Email
Url
Comment *  
Please add 6 and 3 and type the answer here: