[英]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: 请这样做:
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?
这个对吗?
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)
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.
否则请告知。
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.