Registration-Free COM Interop and Dependent Assemblies

狂风中的少年 提交于 2021-02-07 02:50:05

问题


We are working on an integration of a large MFC-based application with a handful of managed (.NET) add-ins. Communication with these add-ins is done via COM.

Historically, we've just used the registry to make these add-ins available (as COM servers) to the application. But, now we're trying to use registration-free COM interop to do this.

We'd like these add-ins to be able to live in a separate directory from the one that the application is running in -- ideally anywhere. But, we're apparently running into problems with the instantiation of the server objects due to the inability to resolve dependent assemblies, which also live in the directory with the COM server DLL.

"Old-fashioned" COM interop handled this by using a LoadFrom context when it loaded the target assembly. But the activation context mechanism doesn't seem to do this.

Does anyone know how to get this to work? It's not clear whether we can identify dependent assemblies in the module's SxS manifest, or perhaps we can create the activation context differently?

Thanks for any thoughts/tips!

Jeff


回答1:


Hope I understand the issue as I'm not so familiar with an MFC project nor it's constraints. How about a "well-known" .NET class with an interface (permanently registered with the MFC app) that, in turn, handles all the activating and instantiating?

Rodney




回答2:


When I look at the article at Simplify App Deployment with ClickOnce and Registration-Free COM I note that they reference the filename of the registration free COM object DLL in the application manifest. I'm guessing that this filename could be changed to include a directory or such.

Secondly, in the section "A More Complex Example", they include dependent COM objects as references to their project and sets them as isolated. That is, they are now also registration free. My guess is that their path could also be updated.




回答3:


Have you registered intermediated (interop) dlls with .net framework?

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm "path..\AxInterop.xxx.dll" or C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\regasm "path..\Interop.xxx.dll"

Regards Phani




回答4:


open your visual studio command prompt and try to register your assembly using regasm

regasm /tlb:"path"


来源:https://stackoverflow.com/questions/1644779/registration-free-com-interop-and-dependent-assemblies

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