Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net Framework Error (HRESULT 0x8007000B)

Tags:

intel

I have a C# application which was written on a 32bit windows XP machine with Visual Studio 2005. The application runs fine on Windows XP machines, however when I try to run it on a 64bit Windows 7 professional machine, I get the following dialog-box on start up:

enter image description here

Here is the full text from the details.

  See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at ICSNeoCSharp.IcsNeoDll.icsneoTxMessages(Int32 hObject, IcsSpyMessage& pMsg, Int32 lNetworkID, Int32 lNumMessages)
   at ICSNeoCSharp.FormDTCApplication.transmitFlowControl(Int32 myArbID) in C:\Documents and Settings\Administrator\Desktop\Adam Stuff ThinkPad\DTC Checker FINAL\frmDTCApp.cs:line 1750
   at ICSNeoCSharp.FormDTCApplication.flowControlTimer_Tick(Object sender, EventArgs e) in C:\Documents and Settings\Administrator\Desktop\Adam Stuff ThinkPad\DTC Checker FINAL\frmDTCApp.cs:line 5166
   at System.Windows.Forms.Timer.OnTick(EventArgs e)
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5472 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
DTC Checker V1.0
    Assembly Version: 1.0.4960.25549
    Win32 Version: 1.0.4960.25549
    CodeBase: file:///C:/DTC%20Checker%20V1.0%20R3/DTC%20Checker%20V1.0%20R3.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5468 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5467 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5467 (Win7SP1GDR.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.Office.Interop.Excel
    Assembly Version: 12.0.0.0
    Win32 Version: 12.0.6600.1000
    CodeBase: file:///C:/Windows/assembly/GAC/Microsoft.Office.Interop.Excel/12.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

Has anyone else encountered this error and succeeded in solving it?

like image 234
Adam Jakiela Avatar asked Aug 02 '13 02:08

Adam Jakiela


People also ask

How do you fix an attempt was made to load a program with an incorrect format exception from Hresult 0x8007000B?

(Exception from HRESULT: 0x8007000B) Print. Solution: This issue arises when there is a 32 bit/64 bit mismatch between the Argon2 DLL and the application that you are using. Basically you will need to ensure that if you are targeting 64 bit you're using the 64 bit binary and vice versa.

What is System Badimageformatexception?

This exception is thrown when the file format of a dynamic link library (. dll file) or an executable (.exe file) doesn't conform to the format that the common language runtime expects.


3 Answers

While your main app might be built for AnyCPU are you sure all the assemblies are AnyCPU? Do you have any native assemblies or assemblies that contain native code? Are they built against x86?

file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll

This tells me that the app is running as an x64 process but it would appear that there is some assembly that isn't AnyCPU or x64 which is likely the cause of the BadImageFormatException.

One thing you can try is to run the application from a 32-bit command prompt (c:\windows\SysWow64\cmd.exe) to force it to be a 32-bit process and see if that works. If that works then there is definitely some assembly that is not AnyCPU.

like image 110
Wes Haggard Avatar answered Sep 16 '22 14:09

Wes Haggard


Project Properties -> Build -> Platform target -> x86 may solve this problem.

like image 20
Yuliia Ashomok Avatar answered Sep 17 '22 14:09

Yuliia Ashomok


One of the most common mistake is we forgot to change the test program and wrapper program to the correct platform. See the below image

enter image description here

(in the top bar it is showing the platform is x64 but you need to make sure if it is really exists in the 2nd image ...)

enter image description here

Make sure you have right configuration on the Configuration Manager...if your config do not match with the actual config of your c++ dll it will give BadImageFormatException.

I learned from the mistake after searching a lot ... and finally got this

like image 35
MD. Nazmul Kibria Avatar answered Sep 19 '22 14:09

MD. Nazmul Kibria