CoCreateInstance of a COM+ component fails with 0x8007007e “The specified module could not be found”

StackOverflow https://stackoverflow.com/questions/20793456

  •  21-09-2022
  •  | 
  •  

Вопрос

I have a COM+ component running as an in-process server (library application) in the COM+ catalog under 64 bit Windows Server 2008 or 64 bit Windows 7. If I install a 32 bit version of the component in C:\Windows\System32 and run:

HRESULT hr = CoCreateInstance(CLSID_MyClsID, NULL, CLSCTX_INPROC_SERVER, IID_MyInterface, reinterpret_cast<void**>(&_interfaceInstance));

from a 32 bit application everything works. Likewise if I install a 64 bit version of the component under C:\ and call CoCreateInstance from a 64 bit application it runs as expected. However if I install a 64 bit version of the component under C:\Windows\System32 and attempt to call CoCreateInstance from a 64 bit application the return value is 0x8007007e, meaning "The specified module could not be found". I am particularly careful about unregistering the component before moving it. I have also checked that the InProcServer keys in the registry point to the actual path to the COM+ dll. What I can't understand is why everything works except for the 64 bit install under C:\Windows\System32??? Any thoughts or ideas hugely appreciated.

Это было полезно?

Решение

Installing your component to C:\Windows\System32 seems like a bad idea in general: that folder is owned by the OS and isn't intended for the installation of user programs.

That said, you're probably being bitten by file system redirection: when a 32-bit program access C:\Windows\System32, it's actually redirected to C:\Windows\SysWOW64. If your installer is 32-bit, it's not actually writing your 64-bit component to the folder you expect. When your 64-bit app runs, it tries to find the component in the "real" System32 folder and fails to find it.

I would recommend installing the two different versions of your component to x86 and x64 subfolders of a new folder under %ProgramFiles%.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top