1. ホーム
  2. c#

[解決済み] .net Framework エラー (HRESULT 0x8007000B)

2022-02-26 03:40:50

質問

32bitのWindows XPマシンでVisual Studio 2005を使って書いたC#アプリケーションがあります。このアプリケーションはWindows XPマシンでは問題なく動作しますが、64bitのWindows 7 professionalマシンで実行しようとすると、起動時に次のようなダイアログボックスが表示されます。

以下は詳細からの全文です。

  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.

このエラーに遭遇し、解決に成功した方はいらっしゃいますか?

解決方法は?

メイン・アプリケーションは AnyCPU 用にビルドされているかもしれませんが、すべてのアセンブリが AnyCPU であることを確認していますか?ネイティブ・アセンブリまたはネイティブ・コードを含むアセンブリがありますか?それらはx86に対してビルドされていますか?

ファイル:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll

このことから、アプリは x64 プロセスとして実行されていることがわかりますが、AnyCPU でも x64 でもないアセンブリが存在し、それが BadImageFormatException の原因である可能性が高いと思われます。

1 つの方法として、32 ビットのコマンド プロンプト (c:\windowsSysWow64cmd.exe) からアプリケーションを実行して、32 ビット プロセスになるように強制して、それがうまくいくかどうかを確認できます。それがうまくいくなら、AnyCPUではない何らかのアセンブリがあることは間違いありません。