WinForms Host, Delphi NonVisualPlugin, and cross platform bi-directional interfaces

(Steve) #1

I am trying to implement bi-directional interfaces between a WinForms host and a Delphi non-visual plugin. Attached are my sample projects. I can create the non-visual plugin and use its methods. What I cannot do is get the non-visual plugin to use the interface methods in the host (e.g., callbacks). Can you please take a look and let me know what I’m doing wrong? (5.9 KB) (823.8 KB)

(antonk) #2


It seems that you run into some kind of limitations of .NET implementation of COM (it is not very good with COM interfaces inheritance).

I suggest you define a separate interface for your callback methods and then set it explicitly. F.e. in your sample it would look like

  // Original Name: TestPlugin.ITestInterface
  ITestInterface = interface(IHYCrossPlatformInterface)
    function ConsumeMessage(const Msg: WideString): WideString; safecall;
    procedure SetCallbackSite(const site: ICallbackSite); safecall;

  // Original Name: TestPlugin.ICallbackSite
  ICallbackSite = interface(IHYCrossPlatformInterface)
    function ConsumeMessageCallback(const Msg: WideString): WideString; safecall;


(Steve) #3

Thanks, that works.

Oh, and a small thing, but when you import .pas interfaces in Visual Studio 2017 (other versions?), it doesn’t separate the file extension in the .cs filename. Screenshot is attached.


(RemObjects) #4

Thanks, logged as bugs://79818

(antonk) #5

Thanks for the report

(RemObjects) #6

bugs://79818 got closed with status fixed.