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

**URL:** https://talk.remobjects.com/t/winforms-host-delphi-nonvisualplugin-and-cross-platform-bi-directional-interfaces/15851
**Category:** Hydra
**Created:** [March 20, 2018, 2:01pm UTC](https://talk.remobjects.com/t/winforms-host-delphi-nonvisualplugin-and-cross-platform-bi-directional-interfaces/15851 "2018-03-20T14:01:14Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![sharpened](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@sharpened](https://talk.remobjects.com/u/sharpened)
#### Post date: [March 20, 2018, 2:01pm UTC](https://talk.remobjects.com/t/winforms-host-delphi-nonvisualplugin-and-cross-platform-bi-directional-interfaces/15851/1 "2018-03-20T14:01:15Z")

</div>

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?

[TestPluginLibrary.zip](https://talk.remobjects.com/uploads/default/original/2X/a/a4ac93f0a74a430b90b0de808f2d68ca15dd02be.zip) (5.9 KB)  
[TestPluginHost.zip](https://talk.remobjects.com/uploads/default/original/2X/c/ce7518eb32ea599ed85ab711052c0599f230b270.zip) (823.8 KB)

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [March 20, 2018, 3:47pm UTC](https://talk.remobjects.com/t/winforms-host-delphi-nonvisualplugin-and-cross-platform-bi-directional-interfaces/15851/2 "2018-03-20T15:47:23Z")

</div>

Hello

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)
  ['{0f9d9dbc-bb10-4c03-930c-e5987ef39aa7}']
    function ConsumeMessage(const Msg: WideString): WideString; safecall;
    procedure SetCallbackSite(const site: ICallbackSite); safecall;
  end;

  // Original Name: TestPlugin.ICallbackSite
  ICallbackSite = interface(IHYCrossPlatformInterface)
  ['{d8ae3524-7237-4abe-aa9b-18a3fca2b16c}']
    function ConsumeMessageCallback(const Msg: WideString): WideString; safecall;
  end;

```

Regards

---

<div class="post-metadata">

### Author: ![sharpened](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/s/a4c791/32.png) [@sharpened](https://talk.remobjects.com/u/sharpened)
#### Post date: [March 20, 2018, 4:27pm UTC](https://talk.remobjects.com/t/winforms-host-delphi-nonvisualplugin-and-cross-platform-bi-directional-interfaces/15851/3 "2018-03-20T16:27:04Z")

</div>

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.

 ![34%20AM](https://talk.remobjects.com/uploads/default/original/2X/8/89055aea3516c67d998dee121943dadac6a63df4.png)

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [March 20, 2018, 5:21pm UTC](https://talk.remobjects.com/t/winforms-host-delphi-nonvisualplugin-and-cross-platform-bi-directional-interfaces/15851/4 "2018-03-20T17:21:43Z")

</div>

Thanks, logged as bugs://79818

---

<div class="post-metadata">

### Author: ![antonk](https://talk.remobjects.com/letter_avatar_proxy/v4/letter/a/a5b964/32.png) [@antonk](https://talk.remobjects.com/u/antonk)
#### Post date: [March 20, 2018, 5:22pm UTC](https://talk.remobjects.com/t/winforms-host-delphi-nonvisualplugin-and-cross-platform-bi-directional-interfaces/15851/5 "2018-03-20T17:22:16Z")

</div>

Thanks for the report

---

<div class="post-metadata">

### Author: ![RemObjectsSoftware](https://talk.remobjects.com/user_avatar/talk.remobjects.com/remobjectssoftware/32/15947_2.png) [@RemObjectsSoftware](https://talk.remobjects.com/u/RemObjectsSoftware)
#### Post date: [August 7, 2018, 10:57am UTC](https://talk.remobjects.com/t/winforms-host-delphi-nonvisualplugin-and-cross-platform-bi-directional-interfaces/15851/6 "2018-08-07T10:57:12Z")

</div>

bugs://79818 got closed with status fixed.
