我的Visual Studio 2010解决scheme有C DLL和C#项目,它调用C DLL。 在32位Windows-7 Pro计算机上构build解决scheme时工作正常。 在64位Windows-7 Pro上,构build好,但运行时,C#调用DLL中的函数,并得到错误:
A first chance exception of type 'System.BadImageFormatException'
解决schemeConfiguration Manager设置是:
<DLL project> Platform = Win32 (<<< no option to change to "Any cpu") <C# project> Platform = "Any cpu"
以下输出是:
C DLLbuild立输出
WPF将html写入一个富文本框
什么是使用用户提供的密码encryption和解密string的简单方法,在本机Win32和.NET中都可以使用?
Windows:列出并启动与扩展名关联的应用程序
Powershell Get-Content + Invoke-Expression单独执行语句,还是一次执行所有语句?
如何最大限度地减lessWindows内存使用量
C#构build输出
运行输出
C DLL构build输出:
1>------ Rebuild All started: Project: Ultrasound_Frame_Grabber,Configuration: Debug Win32 ------ 1> Processing ......includeUSGFWSDKincludeUsgfw2.idl 1> Usgfw2.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeoaidl.idl 1> oaidl.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeobjidl.idl 1> objidl.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeunknwn.idl 1> unknwn.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludewtypes.idl 1> wtypes.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludebasetsd.h 1> basetsd.h 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeguiddef.h 1> guiddef.h 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeocidl.idl 1> ocidl.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeoleidl.idl 1> oleidl.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeservprov.idl 1> servprov.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeurlmon.idl 1> urlmon.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludemsxml.idl 1> msxml.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludestrmif.idl 1> strmif.idl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludecontrol.odl 1> control.odl 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeoaidl.acf 1> oaidl.acf 1> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeocidl.acf 1> ocidl.acf 1> stdafx.cpp 1> DIBSectn.cpp 1> sample.cpp 1> sampleDlg.cpp 1> Ultrasound_Frame_Grabber.cpp 1> Generating Code... 1> Usgfw2_i.c 1> .NETFramework,Version=v4.0.AssemblyAttributes.cpp 1> Creating library C:PrimaryPROJECTSVasoNovaWORKWin7 VPSDebugUltrasound_Frame_Grabber.lib and object C:PrimaryPROJECTSVasoNovaWORKWin7 VPSDebugUltrasound_Frame_Grabber.exp 1>strmbasd.lib(mtype.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification 1> sample.vcxproj -> C:PrimaryPROJECTSVasoNovaWORKWin7 VPSDebugUltrasound_Frame_Grabber.dll ========== Rebuild All: 1 succeeded,0 Failed,0 skipped ==========
2)C#构build输出:
1>------ Skipped Rebuild All: Project: VNMath,Configuration: Debug Win32 ------ 1>Project not selected to build for this solution configuration 2>------ Skipped Rebuild All: Project: GuiManager,Configuration: Debug Any cpu ------ 2>Project not selected to build for this solution configuration 3>------ Rebuild All started: Project: Ultrasound_Frame_Grabber,Configuration: Debug Win32 ------ 4>------ Skipped Rebuild All: Project: VNCommon,Configuration: Debug Any cpu ------ 4>Project not selected to build for this solution configuration 5>------ Skipped Rebuild All: Project: AudioUtility,Configuration: Debug Any cpu ------ 5>Project not selected to build for this solution configuration 6>------ Skipped Rebuild All: Project: VNDevices,Configuration: Debug Any cpu ------ 6>Project not selected to build for this solution configuration 7>------ Skipped Rebuild All: Project: SimpleRPC,Configuration: Debug Any cpu ------ 7>Project not selected to build for this solution configuration 8>------ Skipped Rebuild All: Project: VNSockCommunication,Configuration: Debug Any cpu ------ 8>Project not selected to build for this solution configuration 9>------ Skipped Rebuild All: Project: PdfSharp,Configuration: Debug Any cpu ------ 9>Project not selected to build for this solution configuration 10>------ Skipped Rebuild All: Project: VNUserControls,Configuration: Debug Any cpu ------ 10>Project not selected to build for this solution configuration 11>------ Skipped Rebuild All: Project: GuiServer,Configuration: Debug Any cpu ------ 11>Project not selected to build for this solution configuration 3> Processing ......includeUSGFWSDKincludeUsgfw2.idl 3> Usgfw2.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeoaidl.idl 3> oaidl.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeobjidl.idl 3> objidl.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeunknwn.idl 3> unknwn.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludewtypes.idl 3> wtypes.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludebasetsd.h 3> basetsd.h 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeguiddef.h 3> guiddef.h 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeocidl.idl 3> ocidl.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeoleidl.idl 3> oleidl.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeservprov.idl 3> servprov.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeurlmon.idl 3> urlmon.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludemsxml.idl 3> msxml.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludestrmif.idl 3> strmif.idl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludecontrol.odl 3> control.odl 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeoaidl.acf 3> oaidl.acf 3> Processing C:Program Files (x86)Microsoft SDKsWindowsv7.0Aincludeocidl.acf 3> ocidl.acf 3> stdafx.cpp 3> DIBSectn.cpp 3> sample.cpp 3> sampleDlg.cpp 3> Ultrasound_Frame_Grabber.cpp 3> Generating Code... 3> Usgfw2_i.c 3> .NETFramework,Version=v4.0.AssemblyAttributes.cpp 3> Creating library C:PrimaryPROJECTSmy_projectWORKWin7 VPSDebugUltrasound_Frame_Grabber.lib and object C:PrimaryPROJECTSmy_projectWORKWin7 VPSDebugUltrasound_Frame_Grabber.exp 3>strmbasd.lib(mtype.obj) : warning LNK4075: ignoring '/EDITANDCONTINUE' due to '/INCREMENTAL:NO' specification 3> sample.vcxproj -> C:PrimaryPROJECTSmy_projectWORKWin7 VPSDebugUltrasound_Frame_Grabber.dll 12>------ Rebuild All started: Project: MY_APP,Configuration: Debug Any cpu ------ C:PrimaryPROJECTSmy_projectWORKWin7 VPSMY_APPFrmMY_APP.cs(291,4): warning CS0162: Unreachable code detected C:PrimaryPROJECTSmy_projectWORKWin7 VPSMY_APPFrmMY_APP.cs(441,4): warning CS0164: This label has not been referenced C:PrimaryPROJECTSmy_projectWORKWin7 VPSMY_APPFrmMY_APP.cs(1276,13): warning CS0219: The variable 'exportFrmIsUp' is assigned but its value is never used C:PrimaryPROJECTSmy_projectWORKWin7 VPSMY_APPFrmMY_APP.cs(91,66): warning CS0067: The event 'VN.Forms.MY_APPForm.m_eventTabletConnectionStatusChanged' is never used Compile complete -- 0 errors,4 warnings 12> MY_APP -> C:PrimaryPROJECTSmy_projectWORKWin7 VPSMY_APPbinDebugMY_APP.exe 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibraryCommon.Logging.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibraryCommon.Logging.Log4Net.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibrarydistributedFileSystem.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibraryICSharpCode.SharpZipLib.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibrarylibmobiledevice.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibrarylog4net.config 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibrarylog4net.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibraryNetworkCommsDotNet.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibraryprotobuf-net.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibraryQuickLZCompressor.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibrarySerializerBase.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibrarySevenZipLZMACompressor.dll 12> C:PrimaryPROJECTSmy_projectWORKWin7 VPS\CommsLibrarySharpZipLibCompressor.dll 12> 13 file(s) copied. ========== Rebuild All: 2 succeeded,10 skipped ==========
3)运行输出:
'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_64mscorlibv4.0_4.0.0.0__b77a5c561934e089mscorlib.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.VisualStudio.HostingProcess.UtilitiES10.0.0.0__b03f5f7f11d50a3aMicrosoft.VisualStudio.HostingProcess.Utilities.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Windows.Formsv4.0_4.0.0.0__b77a5c561934e089System.Windows.Forms.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Drawingv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Drawing.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystemv4.0_4.0.0.0__b77a5c561934e089System.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.VisualStudio.HostingProcess.Utilities.Sync10.0.0.0__b03f5f7f11d50a3aMicrosoft.VisualStudio.HostingProcess.Utilities.Sync.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsassemblyGAC_MSILMicrosoft.VisualStudio.Debugger.Runtime10.0.0.0__b03f5f7f11d50a3aMicrosoft.VisualStudio.Debugger.Runtime.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:PrimaryPROJECTSVasoNovaWORKWin7 VPSMY_APPG4binDebugMY_APP.vshost.exe',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Configurationv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Configuration.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_64System.Datav4.0_4.0.0.0__b77a5c561934e089System.Data.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Corev4.0_4.0.0.0__b77a5c561934e089System.Core.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Deploymentv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.Deployment.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceModelv4.0_4.0.0.0__b77a5c561934e089System.ServiceModel.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.ServiceProcessv4.0_4.0.0.0__b03f5f7f11d50a3aSystem.ServiceProcess.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Web.Extensionsv4.0_4.0.0.0__31bf3856ad364e35System.Web.Extensions.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:WindowsMicrosoft.NetassemblyGAC_MSILSystem.Xmlv4.0_4.0.0.0__b77a5c561934e089System.Xml.dll',Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled. The thread 'vshost.NotifyLoad' (0x197c) has exited with code 0 (0x0). The thread '<No Name>' (0x838) has exited with code 0 (0x0). The thread 'vshost.LoadReference' (0x1744) has exited with code 0 (0x0). 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:PrimaryPROJECTSVasoNovaWORKWin7 VPSMY_APPG4binDebugMY_APP.exe',Symbols loaded. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:PrimaryPROJECTSVasoNovaWORKWin7 VPSMY_APPG4binDebugVN.Common.dll',Symbols loaded. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:PrimaryPROJECTSVasoNovaWORKWin7 VPSMY_APPG4binDebugGuiServer.dll',Symbols loaded. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:PrimaryPROJECTSVasoNovaWORKWin7 VPSMY_APPG4binDebugGuiManager.dll',Symbols loaded. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:PrimaryPROJECTSVasoNovaWORKWin7 VPSMY_APPG4binDebugVNUserControls.dll',Symbols loaded. 'MY_APP.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:PrimaryPROJECTSVasoNovaWORKWin7 VPSMY_APPG4binDebugVNSockCommunication.dll',Symbols loaded.
COMMS STEP 0:MY_APPForm_Load。 我的应用程序现在调用DLL中的交streamfunction,造成这个错误:
A first chance exception of type 'System.BadImageFormatException' occurred in MY_APP.exe
如何使用webkit浏览器引擎build立一个网页浏览器
活动窗口上是否有Windows系统事件更改?
如何监视应用程序是否被打开?
有没有办法把Setter元素放入EventTrigger中?
在C#中存储用户特定数据的最佳方式是什么?
加载'C: Windows Microsoft.Net 程序集 GAC_64 mscorlib …
您的程序以64位进程运行。 您的DLL包含32位非托管代码。 KABOOM。
您需要强制EXE以32位进程运行,以便可以加载DLL。 在“解决方案资源管理器”窗口中右键单击您的EXE项目。 属性,生成选项卡,将平台目标设置从Anycpu更改为x86。 在VS2012上勾选“首选32位”选项。 重复发布配置。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。