Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/.net/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# .net Framework错误(HRESULT 0x8007000B)_C#_.net_X86_64 Bit - Fatal编程技术网

C# .net Framework错误(HRESULT 0x8007000B)

C# .net Framework错误(HRESULT 0x8007000B),c#,.net,x86,64-bit,C#,.net,X86,64 Bit,我有一个C#应用程序,它是用Visual Studio 2005在32位windows XP机器上编写的。该应用程序在Windows XP计算机上运行良好,但当我尝试在64位Windows 7 professional计算机上运行时,启动时会出现以下对话框: 以下是全文的详细内容 See the end of this message for details on invoking just-in-time (JIT) debugging instead of this dialog b

我有一个C#应用程序,它是用Visual Studio 2005在32位windows XP机器上编写的。该应用程序在Windows XP计算机上运行良好,但当我尝试在64位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.
有关调用的详细信息,请参阅此消息的结尾
即时(JIT)调试,而不是此对话框。
**************例外文本**************
System.BadImageFormatException:试图加载格式不正确的程序。(HRESULT的异常:0x8007000B)
在ICSNeoCSharp.IcsNeoDll.icsneoTxMessages(Int32 hObject、IcsSpyMessage&pMsg、Int32 lNetworkID、Int32 lNumMessages)
在C:\Documents and Settings\Administrator\Desktop\Adam Stuff ThinkPad\DTC Checker FINAL\frmdtcapapplication.transmitFlowControl(Int32 myArbID)中的ICSNOECSharp.formdtcapApplication.transmitFlowControl(Int32 myArbID)中
在C:\Documents and Settings\Administrator\Desktop\Adam Stuff ThinkPad\DTC Checker FINAL\frmdtcap.cs第5166行中的ICSNOECSharp.formdtcapApplication.flowControlTimer_勾选(对象发送方,事件参数e)
在System.Windows.Forms.Timer.OnTick(EventArgs e)中
在System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message&m)中
在System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd、Int32 msg、IntPtr wparam、IntPtr lparam)中
**************加载的程序集**************
mscorlib
程序集版本:2.0.0.0
Win32版本:2.0.50727.5472(Win7SP1GDR.050727-5400)
代码库:file:///C:/Windows/Microsoft.NET/Framework64/v2.0.50727/mscorlib.dll
----------------------------------------
DTC检查器V1.0
装配版本:1.0.4960.25549
Win32版本:1.0.4960.25549
代码库:file:///C:/DTC%20Checker%20V1.0%20R3/DTC%20Checker%20V1.0%20R3.exe
----------------------------------------
System.Windows.Forms
程序集版本:2.0.0.0
Win32版本:2.0.50727.5468(Win7SP1GDR.050727-5400)
代码库:file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
系统
程序集版本:2.0.0.0
Win32版本:2.0.50727.5467(Win7SP1GDR.050727-5400)
代码库:file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
系统图
程序集版本:2.0.0.0
Win32版本:2.0.50727.5467(Win7SP1GDR.050727-5400)
代码库:file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
Microsoft.Office.Interop.Excel
程序集版本:12.0.0.0
Win32版本:12.0.6600.1000
代码库:file:///C:/Windows/assembly/GAC/Microsoft.Office.Interop.Excel/12.0.0.0__71e9bce111e9429c/Microsoft.Office.Interop.Excel.dll
----------------------------------------
**************JIT调试**************
要启用即时(JIT)调试,请为
应用程序或计算机(machine.config)必须具有
在system.windows.forms节中设置的值。
应用程序还必须通过调试进行编译
启用。
例如:
启用JIT调试时,任何未处理的异常
将发送到计算机上注册的JIT调试器
而不是由此对话框处理。

是否有其他人遇到此错误并成功解决了此问题?

根据我的经验,导致此错误的原因是.Net Framework版本

检查您的.Net Framework版本和更新,以及
检查应用程序的.Net版本。

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

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

这告诉我,该应用程序正在以x64进程的形式运行,但似乎有一些程序集不是AnyCPU或x64,这可能是导致BadImageFormatException的原因


您可以尝试从32位命令提示符(c:\windows\SysWow64\cmd.exe)运行应用程序,强制它成为32位进程,并查看是否有效。如果这样做有效,那么肯定有一些程序集不是任何CPU。

项目属性->构建->平台目标->x86可以解决此问题

我的问题通过使用32位进行编译得到解决,因为Wix目前没有64位。您的安装程序msi在任何情况下都是64位的


在我的例子中,我出现了0x8007000B错误,因为该应用程序在64 windows 7上以32位运行。我通过进入windows/syswov64文件夹将MSVCR110.dll版本的64位更改为MSVCR110.dll版本的32位来解决这个问题

(只是别忘了在之后放回64 dll。每次需要运行32位应用程序时,只需将dll移到32位即可)


您可以找到dll版本(在粘贴到syswov64文件夹之前将其解压缩)。

我还想添加我的发现:我在“构建”选项卡a的“项目属性”中未选中“首选32位”,并出现此错误。经过重新检查,它不见了。我将任何CPU设置为目标


我知道这不是一个确定的解决方案,只是一个症状解决方案,但它可能会有所帮助。

我的解决方案是更改IIS中的应用程序池。打开应用程序池属性并转到高级设置。。。然后将“启用32位应用程序”更改为True。新的默认值为False。代码部分被设置为“任意CPU”,尽管我过去通过将CPU设置为x86解决了问题。

最常见的错误之一是我们忘记将测试程序和包装程序更改为正确的平台。请参见下图

(在顶栏中,它显示平台为x64,但您需要确保它是否确实存在于第二张图像中…)

确保配置正确