实例化一个COM组件失败,"没有注册类"当"以管理员身份运行" [英] Instantiating a COM Component fails with "Class not registered" when "Run As Administrator"

查看:306
本文介绍了实例化一个COM组件失败,"没有注册类"当"以管理员身份运行"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当实例化一个COM互操作的对象:

When instantiating a COM Interop object:

var comObj = new ComComponentClass();



我得到的收到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.

注:


  • 该应用程序是64位应用程序。

  • COM组件是一个64位的DLL一个inproc服务器。

任何想法,我应该开始研究为什么这种差异会发生?

Any ideas as to where I should start investigating why this difference occurs?

我已经试过:

我已经使用将procmon观看什么注册表项它会检查。

I've used Procmon to watch what registry keys it inspects.


  • 在这两种情况下,相应的DLL位于通过检查键 HKCU\Software\Classes\ CLSID\ {C343ED84-A129-11d3-B799-0060B0F159EF} \InprocServer32

  • 在这两种情况下,查询键 HKCR\\ \\CLSID\ {C343ED84-A129-11D3-B799-0060B0F159EF} 和回来找不到名称。我奇怪的(因为我可以通过找到键 REGEDIT.EXE ,但因为这并不在两种情况之间的差异,似乎找到没有重要的。

  • In both cases, the appropriate dll is located by inspecting the key HKCU\Software\Classes\CLSID\{C343ED84-A129-11d3-B799-0060B0F159EF}\InprocServer32
  • In both cases it queries the key 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.

推荐答案

您注册的对象为您的本地用户帐户没有管理权限,而不是从一个这样做行政程序正因为如此,COM组件是注册表的用户特定区域下注册。(正如你指出:HKC *的 U 的*)

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* ).

当一个进程没有管理权限运行时,它呈现的HKCR注册表的合并视图,其中包括在不是招'HKLM\Software\Classes所有HKCU\Software\Classes项加什么吨HKCU\Software\Classes被重写。当一个进程作为管理员,注册表只显示HKLM\Software\Classes项。

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.

请参阅此链接查看更多细节:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724498(v = vs.85)的.aspx

See this link for more details: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724498(v=vs.85).aspx

奇怪的是,会的RegSvr32不HKCU\Classes项下注册。如果您没有管理权限运行它,它只会失败(只是检查,以确保在Windows 7中)。如何在COM组件注册?

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?

这篇关于实例化一个COM组件失败,"没有注册类"当"以管理员身份运行"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆