简体   繁体   English

从主COM服务器中公开的接口创建辅助COM Server

[英]Create secondary COM Server from interfaces exposed in primary COM Server

I have a need to define an interface in C# (eg ICommonHandler) and have it implemented in Delphi, or, for that matter any other language. 我需要在C#中定义一个接口(例如ICommonHandler),并在Delphi中实现,或者就此而言,可以使用任何其他语言来实现。 For now, the priority is in Delphi. 目前,在Delphi中是优先事项。

From C# I then need to instantiate instances of interface ICommonHandler via classes that's implemented in Delphi. 然后,从C#中,我需要通过在Delphi中实现的类实例化接口ICommonHandler的实例。

To summarize the above, I have a 'contract' exposed from C#. 综上所述,我从C#中获得了一个“合同”。 My C# code then expects implementations of this contract from Delphi, or then any arbitrary language. 然后,我的C#代码需要Delphi或任何任意语言的合同实现。

Is the above possible? 以上可能吗? If so, I'd very much appreciate possible guidelines on how to get it going. 如果是这样,我将非常感谢有关如何进行的可能指导。

My feeling is that the above will not be possible, because one cannot register multiple COM servers containing the same GUID for the same interface, in this case ICommonHandler. 我的感觉是,以上操作是不可能的,因为不能为同一接口注册多个包含相同GUID的COM服务器,在本例中为ICommonHandler。

"My feeling is that the above will not be possible, because one cannot register multiple COM servers containing the same GUID for the same interface, in this case ICommonHandler." “我的感觉是,以上操作是不可能的,因为不能为同一接口注册多个包含相同GUID的COM服务器,在本例中为ICommonHandler。” That is simply not true! 很显然这不是真的! Whoever gave you that idea? 谁给你这个主意的? If your delphi code exposes ICommonHandler that's enough. 如果您的delphi代码公开了ICommonHandler,那就足够了。

In C#: generate a COM project that compiles to a DLL with just the type library in it, describing ICommonHandler. 在C#中:生成一个COM项目,该项目仅在其中包含类型库的情况下编译为DLL,描述ICommonHandler。

In Delphi: import the Type Library from this DLL, optionally having the importer generate wrapper objects for them. 在Delphi中:从此DLL导入类型库,可以选择使导入程序为其生成包装对象。 (I personally prefer not to and use the raw interface instance references) (我个人不希望使用和使用原始接口实例引用)

Then, using this CommonHandler_TLB.pas in a ActiveX Library project of your own, create descendants of TInterfacedObject or TAutoObject that implement ICommonHandler. 然后,在您自己的ActiveX库项目中使用此CommonHandler_TLB.pas ,创建实现ICommonHandler的TInterfacedObject或TAutoObject的后代。 If you use the File > New > Other... wizards under ActiveX, a specific ClassID and needed code will be gerated for you. 如果在ActiveX下使用“文件”>“新建”>“其他...”向导,则将为您编写特定的ClassID和所需的代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM