.net框架错误(HRESULT 0x8007000B)

Ada*_*ela 16 .net c# 64-bit x86

我有一个使用Visual Studio 2005在32位Windows XP机器上编写的C#应用​​程序.该应用程序在Windows XP机器上运行良好,但是当我尝试在64位Windows 7专业机器上运行它时,我得到以下对话框在启动时:

在此输入图像描述

这是详细信息的全文.

  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.
Run Code Online (Sandbox Code Playgroud)

有没有其他人遇到过这个错误并成功解决了它?

Wes*_*ard 19

虽然您的主应用程序可能是为AnyCPU构建的,但您确定所有程序集都是AnyCPU吗?您是否有任何包含本机代码的本机程序集或程序集?它们是针对x86构建的吗?

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

这告诉我该应用程序正在作为x64进程运行,但看起来有一些程序集不是AnyCPU或x64,这可能是BadImageFormatException的原因.

您可以尝试的一件事是从32位命令提示符(c:\ windows\SysWow64\cmd.exe)运行该应用程序,以强制它是一个32位进程,看看是否有效.如果这样可行,那么肯定会有一些不是AnyCPU的程序集.

  • 我在x86中构建了这个项目并且它有效. (2认同)

Yul*_*mok 7

Project Properties -> Build -> Platform target -> x86可以解决这个问题。