Regasm 将 mscoree.dll 写入注册表项 InprocServer32
当我使用 regasm.exe 注册 .NET 程序集时,注册表项
HKEY_CLASSES_ROOT\CLSID{111E32AD-4BF8-495F-AB4D-6C61BD463EA4}\InprocServer32
设置为“mscoree.dll”。
但是,我试图模仿用 C 编写的现有 COM 服务器。注册此旧 COM 服务器时,InprocServer32 设置为该组件的完整路径。
不幸的是,现有系统(我无法更改的插件主机)读取并使用此值 - 被“mscoree.dll”值混淆。
我的解决方案可能是手动修补此注册表项 - 但我想了解为什么 regasm 将“mscoree.dll”写入 InprocServer32 。
When I register my .NET Assembly with regasm.exe the registry key
HKEY_CLASSES_ROOT\CLSID{111E32AD-4BF8-495F-AB4D-6C61BD463EA4}\InprocServer32
is set to "mscoree.dll".
However, I am trying to mimic an existing COM-Server that was written in C. When registering this old COM-server the InprocServer32 is set to the full path to this component.
Unfortunately the existing system (a plugin host that I can not change) reads and use this value - an is confused by the "mscoree.dll" value.
My solution might be to patch this registry entry manually - but I would like to understand why regasm writes "mscoree.dll" into InprocServer32 .
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解释很简单。当您在进程内使用本机(非托管)COM 服务器时,它会被加载到消费者进程中,并且消费者进程会直接调用其函数。
对于托管代码 COM 公开的程序集来说,这不能那么容易地工作。对于托管代码,需要一个中间层来执行托管/非托管交互。
mscoree.dll
充当此中间层。因此,当使用者调用CoCreateInstance()
时,会加载mscoree.dll
并通过加载 COM 公开的程序集托管代码来模拟 COM 服务器,并将所有调用转发给后者。The explanation is quite easy. When you use a native (unmanaged) COM server in-proc, it is loaded into the consumer process and the consumer process directly calls its functions.
This can't work that easily with a managed code COM-exposed assembly. In case of managed code an intermediate layer is needed that performs the managed/unmanaged interaction.
mscoree.dll
acts as this intermediate layer. So when the consumer callsCoCreateInstance()
mscoree.dll
is loaded and emulates the COM server by loading the COM-exposed assembly managed code and forwardind all calls to the latter.