DCOM server and client both written in .NET

不打扰是莪最后的温柔 提交于 2019-12-01 20:59:42

I managed to get DCOM working, but I'm not certain if it can be done from a TypeLib. Modifying the IDL allowed me to import the type library, but it eventually failed during compilation (although this is treated as a warning by Visual Studio). It might still be possible to make even more modifications to the file, but I'm using a much easier solution.

All the interface definitions for the DCOM server were moved to a separate assembly, which is then referenced directly from the .NET client. This circumvents the importing problem.

Then, accessing the DCOM server is no different from what one might expect:

Guid clsId = new Guid("XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX");
Type type = Type.GetTypeFromCLSID(clsId);
IMyInterface comObject = (IMyInterface)Activator.CreateInstance(type);

Moving the interfaces to a separate assembly is not strictly necessary, but this minimizes the size of the shared assembly.

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