.net框架错误(HRESULT 0x8007000B)

我有一个使用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:    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的原因。

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

项目属性 – >构建 – >平台目标 – > x86可以解决这个问题。

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

在此处输入图像描述

(在顶部栏中显示平台是x64,但你需要确保它是否真的存在于第二张图片……)

在此处输入图像描述

确保在Configuration Manager上有正确的配置…如果您的配置与c ++ dll的实际配置不匹配,它将给出BadImageFormatException。

经过大量搜索后我从错误中吸取了教训……最终得到了这个

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

检查.Net Framework版本并进行更新,并检查应用程序的.Net版本。

在我的情况下,我有0x8007000B错误,因为应用程序在我的64个窗口7上运行32位。我解决了它通过在Windows / syswov64文件夹中更改MSVCR110.dll版本64位与MSVCR110.dll版本32位。

(只是不要忘记在之后放回64 dll,每次需要运行32位应用程序时放回dll 32)。

你可以在这里找到dll版本(在粘贴到syswov64文件夹之前解压缩它)。

我的问题通过32位编译解决,因为Wix目前没有64位。你的安装程序msi无论如何都是64位

http://windows-installer-xml-wix-toolset.687559.n2.nabble.com/64bit-bootstrapper-using-wix-td7582851.html

我想补充一下我的发现:我在Build选项卡的项目属性中取消选中了“Prefer 32-bit”并得到了这个错误。 重新检查后,它消失了。 我有任何CPU设置为目标。

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

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

当我的解决方案称为32位dll时,我遇到了这个错误。 除了进行上述其他回复中提到的平台更改之外,在VS2017 Project {yourproject}属性服务中,我还必须将“使用Windows身份validation”更改为“使用表单身份validation”

选择“服务”选项卡,然后在“身份验证”部分中选择“使用表单身份验证”并以红色圈出

我必须结合2-3个不同答案的解决方案来解决同样的错误。 原因是,最终设置有来自x86和x64平台的dll(在单独的文件夹中用于单独的exes)。

1)我将主应用程序的平台目标设置为64位并保留配置设置并构建它: 在此处输入图像描述

2)我将Deployment项目的Target平台设置为x64。

3)dll在文件夹之间混合,所以我逐个检查文件类型编辑器中所有dll的源路径,并根据它们的体系结构替换它们。

4)最后使用以下配置设置构建了部署项目: 在此处输入图像描述

上面提到的组合是唯一有效的组合。