Register C# COM Object without having a real file for RegAsm

假如想象 提交于 2019-12-02 09:46:18

I'm doing something very similar in Excel-DNA. You don't have to deserialize the COM types to disk, or register them in advance. What I did is to define a class that implements IClassFactory, then register it as the current class factory for the particular CLSID (type) by calling CoRegisterClassObject. When COM tries to create the object, your class factory is called and can return an instance of your .NET type.

Depending on the context, you might have to deal with the ProgID / CLSID registration on the fly.

(If you contact me I'd be happy to help you grab the right bits from the Excel-DNA code to get you started.)

I digged a little and maybe implementing DllRegisterServer() intot he main executable and then registering all the COM types in all the embedded DLLs would work...

Can anyone confirm?

EDIT: Yes it can be done, but the main executable must be a COM proxy to the DLLs inside.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!