开发者

Who is responsible for calling CoInitialize and CoUninitialize if surrogate process or COM+

Who is responsible for calling CoInitialize and CoUninitia开发者_StackOverflowlize if

1- I host a COM dll within a surrogate process (either by using dcomcnfg utility or COM+ wizard)?

2- I build a ISAPI DLL that contains COM objects?


No idea on case 2, but in case 1 the surrogate process certainly calls CoInitialize()/CoUninitialize(). Here's how I know this.

We have a COM object that we host in COM+ and that itself uses MS XML 4. When you need to create an XML document object in MS XML 4 you call CoCreateInstance(). We never call CoInitialize() in our COM object, yet document creation is always successful - certainly the surrogate calls CoInitialize(). If we do the same in a stand-alone app document creation fails unless we ourself call CoInitialize().

So the bottom line is: COM+ surrogate (and I'm sure that applies to DCOM surrogate as well) calls CoInitialize() itself.

Btw you can use this to investigate the case 2 - call CoCreateInstance() inside the ISAPI dll - if it is successful CoInitialize() has already been called.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜