This sample contains a Delphi host and .NET plugin.
To run this sample build both host and plugin projects. Then run the NewHostApplication.exe. Press the Load Plugin button to load .NET plugin. Then press the Send Event button to call a host Delphi method from .NET plugin.
Let’s take a closer look at the host app code:
The uCustomInterfaces.pas file contains 2 interop interfaces.
The fMain.pas file contains code
HYModuleManager1.LoadModule('ManagedModule.dll');
HYModuleManager1.CreateVisualPlugin('ManagedModule.Plugin1', fPlugin, Panel1);
(fPlugin as IInterfaceThatHasEvents).SetEventSink(Self);
Here a plugin is loaded from dll. Then this plugin is instantiated and then a method of this plugin is called.
As you can see the 1st method is called from the host size. The 2nd method in this code snippet in its turn calls a method in callback interface provided earlier by the host. Essentially it calls a method in the host.
Note that implementation is not tied to a plugin or host having a form. In this sample VisualPlugin is used only to provide a simple way to start a Plugin-> Host method call operation. This approach can as well be used for non-visual plugins.