System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

Hi,

I have VB.net application that I recently migrated from VS2003 to VS2005. It
works fine in Windows XP and 2K but NOT in XP64.

I get an exception error that says System.BadImageFormatException. I checked
the Advanced Compliler Settings and the Target CPU is set to AnyCPU. Setting
it x64 does not make a difference.

If I run my previous copy of the application built in VS2003 on the x64
system, it runs ok.

Any ideas, areas where I need to look for possible solution The application seems to crash at the point where it calls the function below.

' identify the driver test filename using Direct3D

' get adapter information from default adapter

Dim result As String

Dim d3dAdapterDetails As Microsoft.DirectX.Direct3D.AdapterDetails

d3dAdapterDetails = Microsoft.DirectX.Direct3D.Manager.Adapters.Default.Information

result = d3dAdapterDetails.DriverName

'MessageBox.Show(result)

If Not result.ToLower.EndsWith(".dll") Then result += ".dll"

Return result

End Function 'GetDriverFileName

Thanks,
Glenn



Answer this question

System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

  • Ganesh sethuraman

    The problem is in the DirectX dll. It looks like you're using a version that is compiled for x86 instead of x64. Try grabbing a new version from the directx website and make sure to include the x64 version in the program you're running.

    http://msdn.microsoft.com/directx/



  • ZopoStyle

    Hi Jared,

    I have just started to learn DirectX programming and run into the above problem reported by Glenn:

    I installed the latest version of the DirectX SDK (downloaded from http://msdn.microsoft.com/directx/sdk/) on my XP64 and tried to compile the sample C# code with Visual Studio 2005 Professional Trial Version. Then I got the "System.BadImageFormat" exception with the "Additional information: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)". Interestingly, the exe's compiled by the DirectX SDK Team from these sample projects, which came with the same install package, run without problem.

    Do you think this is an x64-specific problem What can I do There was no possibility to choose a specific installer for x64, and XP64 was mentioned on the download page among the supported OS's. I think I would have to set something in Visual Studio...

    I would like to try Managed DirectX programming with C#. Should I go back to do OpenGL programming with C++ No problem, but I would miss Class Designer, which cannot be used with C++ projects :)

    Thank you for your help in advance.
    Regards,
    Laszlo


  • Christopher Ireland

    Good news, I found the solution! The only thing I had to do is to change the "Platform Target" to "x86" in the "Project\Properties" page, on the "Build" tab. This is required because "Managed DirectX does NOT support using 64 bit", see http://exdream.no-ip.info/blog/PermaLink.aspx guid=990a1524-93cb-42bc-b3a9-5106e368cf3e and http://exdream.no-ip.info/blog/PermaLink.aspx guid=8962e9a7-3185-438d-882a-e8e919771dc2. I hope that Microsoft solves this problem soon.

    Thanks, Benjamin!


  • System.BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)