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

0

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:

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.

I've looked everywhre, it seems there are issues registering 32 bit objects on a 64 bit system.

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

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

The exception I get is: System.AccessViolationException

c++
.net
com
asked on Stack Overflow Jun 3, 2015 by Eric Bergman • edited Jun 3, 2015 by too honest for this site

1 Answer

1

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). Is this correct?

  1. Please run dumpbin /all on your binaries and post the results.

Please run dumpbin on all relevant binaries; especially the COM/ActiveX class.

A Win32 .dll should like something like this:

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 won't work with .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. Again, I'm assuming there's only one .exe, and one .dll in the mix.

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. Both should have "PE32" headers in dumpbin. 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.

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!

answered on Stack Overflow Jun 3, 2015 by paulsm4 • edited Jun 4, 2015 by paulsm4

User contributions licensed under CC BY-SA 3.0