Custom COM class factory for managed in-proc serve

2019-05-18 17:09发布

I'm looking at implementing custom COM activation logic for a managed class library, in MkParseDisplayName/BindToObject manner.

This way, creating an object from VB might look like this:

obj = GetObject("clsid:12341234-1234-1234-1234-123412341234:!UniqueObjectId")

That would not be a problem for an out-of-proc server (using CoRegisterClassObject). However, for an in-proc server, I'd need to alter the implementation of DllGetClassObject, which is normally provided by mscoree.dll. Is this possible at all?

The only other option I see is to create a C# singleton object to serve as class factory and implement IParseDisplayName on it. In theory, such singleton could also register a custom IClassFactory class object with CoRegisterClassObject(CLSCTX_INPROC_SERVER), but the singleton itself would need to get instantiated first, anyway.

0条回答
登录 后发表回答