简体   繁体   English

C ++应用程序在64位版本的Windows中崩溃,但在32位Windows上正常运行

[英]C++ application crashes in a 64 bit version of windows but works fine on 32 bit windows

So I have a Visual C++ application, in my code I use the CoCreateInstance function which is used to create a COM object and get an interface from the object: 因此,我有一个Visual C ++应用程序,在我的代码中,我使用了CoCreateInstance函数,该函数用于创建COM对象并从该对象获取接口:

https://msdn.microsoft.com/en-us/library/windows/desktop/ms686615(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/ms686615(v=vs.85).aspx

This function: 该功能:

hr = CoCreateInstance(CLSID_CppCmnBL, NULL, CLSCTX_INPROC_SERVER, 
         IID_ICppCmnBL, reinterpret_cast<void**>(&m_pBL)); 

Works fine on a 32 bit version of windows but fails on a 64 bit version of windows. 在32位版本的Windows上工作正常,但在64位版本的Windows上失败。

I've looked everywhre, it seems there are issues registering 32 bit objects on a 64 bit system. 我看过Everywhre,似乎在64位系统上注册32位对象时遇到问题。

Related issues: 相关问题:

https://social.msdn.microsoft.com/Forums/en-US/3841717c-a736-46d0-b214-0b047efcd16c/32-bit-app-cocreateinstance-failed-on-64-bit-windows-with-error-0x80090006-invalid-signature?forum=vclanguage https://social.msdn.microsoft.com/Forums/en-US/3841717c-a736-46d0-b214-0b047efcd16c/32-bit-app-cocreateinstance-failed-on-64-bit-windows-with-error- 0x80090006-无效签名?论坛= vclanguage

http://forums.codeguru.com/showthread.php?400956-32-bit-app-CoCreateInstance-fails-on-64-bit http://forums.codeguru.com/showthread.php?400956-32-bit-app-CoCreateInstance-fails-on-64-bit

The exception I get is: System.AccessViolationException 我得到的异常是:System.AccessViolationException

Please do this: 请这样做:

  1. Clarify the #/binaries involved. 明确涉及的#/二进制文件。

I assumed you had one .exe (the one calling CoCreateInstance()), and one .dll (the Com/ActiveX object you're trying to instantiate). 我假设您有一个.exe(一个调用CoCreateInstance())和一个.dll(您要实例化的Com / ActiveX对象)。 Is this correct? 这个对吗?

  1. Please run dumpbin /all on your binaries and post the results. 请在您的二进制文件上运行dumpbin /all并发布结果。

Please run dumpbin on all relevant binaries; 请在所有相关的二进制文件上运行dumpbin; especially the COM/ActiveX class. 特别是COM / ActiveX类。

A Win32 .dll should like something like this: Win32 .dll应该像这样:

FILE HEADER VALUES
             14C machine (x86)
               3 number of sections
        5355B2AD time date stamp Mon Apr 21 17:07:09 2014
               0 file pointer to symbol table
               0 number of symbols
              E0 size of optional header
            2102 characteristics
                   Executable
                   32 bit word machine
                   DLL

OPTIONAL HEADER VALUES
             10B magic # (PE32)
  1. Please clarify which binaries you've attempted to rebuild with your MSVS 6 compiler. 请说明您尝试使用MSVS 6编译器重建的二进制文件。

MSVS 6 won't work with .Net; MSVS 6无法与.Net一起使用; MSVS 6 won't build C++11 code ... but it should be fine if all you're trying to do is get a legacy app working. MSVS 6不会构建C ++ 11代码...但是,如果您要尝试做的只是使旧版应用程序正常运行,那应该没问题。 Again, I'm assuming there's only one .exe, and one .dll in the mix. 同样,我假设混合中只有一个.exe和一个.dll。

I'm assuming the .exe can be compiled as a 32-bit Win32 .exe ( not a .Net .exe), and the .dll is a Win32, COM/ActiveX class. 我假设.exe可以编译为32位Win32 .exe( 而不是 .Net .exe),而.dll是Win32,COM / ActiveX类。 Both should have "PE32" headers in dumpbin. 两者在转储中都应具有“ PE32”标头。 Please advise if otherwise. 否则请告知。

I'm assuming you have control over, and can rebuild and debug, ALL of the relevant source code for this app. 我假设您已控制并可以重建和调试此应用程序的所有相关源代码。 Please advise if otherwise. 否则请告知。

  1. You should be able to register a COM/ActiveX .dll with regsvr32. 您应该能够使用regsvr32注册COM / ActiveX .dll。

If you can't, that's probably an indicator that "something is wrong", and I'd focus your troubleshooting efforts there. 如果不能,那可能是“有问题”的指示,我将集中精力进行故障排除。

I hope that helps! 希望对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 C ++ Mex文件使Matlab在64位linux上崩溃,但在32位Windows上没有崩溃,但是程序在Matlab外部运行良好 - C++ Mex file crashes matlab on 64bit linux, but not 32 bit windows, but program runs fine outside Matlab 在Windows 7 64位中开发32位C ++应用程序 - Developing 32-bit C++ application in Windows 7 64-bit 如何在 C++ 上检测是 windows 32 位还是 64 位? - How to detect on C++ is windows 32 or 64 bit? C / C ++ Windows控制台应用程序的速度取决于目标是32位还是64位? - Does speed of an C/C++, Windows console application depend on whether the target is 32 or 64 bit? 在Windows 7中安装Boost C ++的64位版本 - Installing 64 bit version of Boost C++ in Windows 7 如何在Windows7-64bit中为RHEL 6创建C ++应用程序 - How to Create a C++ application for RHEL 6 in Windows7-64bit Visual Studio 2008 Express C ++ 32位在Windows 7 64位上构建 - Visual Studio 2008 Express C++ 32 bit build on Windows 7 64 bit 什么是C ++中的32Bit和64Bit窗口中的兼容“int”类型? - What is Compatible “int” type in both 32Bit & 64Bit windows in C++? C ++ Windows Shell扩展-Win7 32位-64位兼容性问题 - C++ Windows Shell Extensions - Win7 32bit - 64bit compatibility issues C ++ Windows代码链接为64位,但不是32位 - C++ windows code links in 64bit but not in 32bit
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM