When instantiating a COM Interop object:
var comObj = new ComComponentClass();
I get the COMException
:
Retrieving the COM class factory for component with CLSID
{C343ED84-A129-11D3-B799-0060B0F159EF} failed due to the following error:
80040154 Class not registered
(Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
I only get this error when I launch my application with Run as Administrator. When I run normally, the error does not occur.
Notes:
Any ideas as to where I should start investigating why this difference occurs?
What I've tried:
I've used Procmon to watch what registry keys it inspects.
HKCU\Software\Classes\CLSID\{C343ED84-A129-11d3-B799-0060B0F159EF}\InprocServer32
HKCR\CLSID\{C343ED84-A129-11D3-B799-0060B0F159EF}
and gets back NAME NOT FOUND
. Which I find strange (since I can find that key using regedit.exe
. But since this doesn't differ between the two scenarios, it didn't seem important.You registered the object for your local user account without administrative privileges, instead of doing so from an administrative process. Because of that, the COM component is registered under the user-specific area of the registry (as you yourself indicated: HKC*U* ).
When a process runs without administrative privileges, it is presented with a merged view of the HKCR registry, which includes all the HKCU\Software\Classes entries plus anything in HKLM\Software\Classes that hasn't been overridden in HKCU\Software\Classes. When a process runs as administrator, the registry only shows the HKLM\Software\Classes entries.
See this link for more details: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724498(v=vs.85).aspx
The weird thing is, RegSvr32 won't register under the HKCU\Classes key. If you run it without administrative rights, it will just fail (just checked to make sure, in Windows 7). How was the COM component registered?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With