为什么COM忽略我的DllSurrogate条目? [英] Why is COM ignoring my DllSurrogate entry?
问题描述
我知道这个问题,但我已经按照列出的步骤,我仍然困惑。
我有一个类,注册如下(这是一个RGS文件):
HKCR
{
NoRemove CLSID
{
ForceRemove {5Cb1D770-BF72-4F3D-B4DA-85E0542126F4} = s'ExamplePlugin类
{
val AppID = s'%APPID%'
InprocServer32 = s' MODULE%'
{
val ThreadingModel = s'Free'
}
}
}
}
我有一个AppID,注册如下:
HKCR
{
NoRemove AppID
{
'%APPID%'= s'ExamplePlugin'
{
val DllSurrogate = s''
}
'ExamplePlugin.DLL'
{
val AppID = s'%APPID%'
}
}
}
我将
CLSCTX_ALL
传递给CComPtr< IPlugin> :: CoCreateInstance
。
总之,就我所知,我遵循检查清单:
- 我有一个在我的CLSID下指定的AppID值。我有一个相应的AppID密钥。
- 我在激活呼叫中加入了
CLSCTX_LOCAL_SERVER
。我的CLSID键没有任何LocalServer键。
- 我的CLSID键包含InprocServer32键。
- 我假设当检查表说 / stub在InprocServer32中指定的DLL存在,意味着实现DLL。它确实存在。我的代理/存根DLL在其他地方正确注册。
- 我的AppID键下有一个DllSurrogate值。
$ b b如果我在OLE / COM对象查看器中查看我的类,它看起来是正确的(实现选项卡已选中使用代理进程)。
它仍然不工作:我的DLL加载到与我的主机EXE相同的进程。
一个线索:如果我运行Process Monitor,我看不到它寻找值
CLSID \ {...} \AppID
。如果我将CLSCTX_LOCAL_SERVER
传递给CoCreateInstance,则会返回未注册类。
我缺少什么?
div class =h2_lin>解决方案
原来,文档是误导。仅仅设置CLSCTX_LOCAL_SERVER是不够的。您还必须从对CoCreateInstance的调用中删除CLSCTX_INPROC值。如果你不这样做,COM将总是使用in-proc东西,并且永远不会查询DllSurrogate。
I'm aware of this question, but I've followed the steps listed there and I'm still stumped.
I've got a class, registered as follows (this is an RGS file):
HKCR
{
NoRemove CLSID
{
ForceRemove {5CB1D770-BF72-4F3D-B4DA-85E0542126F4} = s 'ExamplePlugin Class'
{
val AppID = s '%APPID%'
InprocServer32 = s '%MODULE%'
{
val ThreadingModel = s 'Free'
}
}
}
}
I've got an AppID, registered as follows:
HKCR
{
NoRemove AppID
{
'%APPID%' = s 'ExamplePlugin'
{
val DllSurrogate = s ''
}
'ExamplePlugin.DLL'
{
val AppID = s '%APPID%'
}
}
}
I'm passing CLSCTX_ALL
to CComPtr<IPlugin>::CoCreateInstance
.
In short, as far as I can tell, I've followed the checklist:
- I have an AppID value specified under my CLSID. I have a corresponding AppID key.
- I've included
CLSCTX_LOCAL_SERVER
in the activation call. My CLSID key does not have any LocalServer keys. - My CLSID key contains an InprocServer32 key.
- I assume that when the checklist says "the proxy/stub DLL specified in InprocServer32 exists", it means "the implementing DLL". It does exist. My proxy/stub DLL is correctly registered elsewhere.
- I have a DllSurrogate value under my AppID key.
If I look at my class in OLE/COM object viewer, it appears to be correct (the Implementation tab has "Use Surrogate Process" checked).
It's still not working: my DLL is loading into the same process as my host EXE.
A clue: If I run Process Monitor, I can't see it looking for the CLSID\{...}\AppID
value. If I pass CLSCTX_LOCAL_SERVER
to CoCreateInstance, I get "class not registered" returned.
I'm on Windows 2008 x64, but I've tried with my code compiled for both x86 and x64 with the same result.
What am I missing?
It turns out that the documentation is misleading. It's not enough merely to set CLSCTX_LOCAL_SERVER. You also have to remove the CLSCTX_INPROC values from the call to CoCreateInstance. If you don't, COM will always use the in-proc stuff, and will never query for DllSurrogate.
这篇关于为什么COM忽略我的DllSurrogate条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!