DCOM server and client both written in .NET

前端 未结 1 1235
死守一世寂寞
死守一世寂寞 2021-01-19 12:27

I\'m developing a DCOM server in .NET 4 (VS2010, C#). By itself, this is working fine.

Now, I also need to develop a .NET client for this DCOM server, but I am unabl

相关标签:
1条回答
  • 2021-01-19 13:11

    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.

    0 讨论(0)
提交回复
热议问题