Need a Jumpstart with Delphi XE3 and .NET 2.0 DLL Assemblies Integration

I read through the docs but still need a jumpstart on how I can use Hydra with some .NET 2.0 DLL assemblies and Delphi XE3. I am trying to integrate some Aspose.Total for .NET components (.NET file conversion libraries) into my Delphi VCL “host” application as non-visual plugins. These libraries are .NET 2.0 assemblies stored in DLLs. They are not interfaces “suitable for import,” however, so in Delphi XE3 I can’t just do Hydra -> Import Interfaces from .NET Assemblies. It reports:

“The selected assemblies contain no interfaces suitable for import. Please check messages for details.”

(I don’t know where the “messages” are or really what this means).

What should be my strategy for integrating these libraries? Do I have to build a “suitable” custom interface in something like Visual Studio first? For example, do I write a simpler .NET interface that performs my needed conversions with the Aspose.Total libraries in Visual Studio, compile it in to a .NET DLL assembly, and then create a non-visual plugin out of it with Hydra–and then invoke the plugin interface routines with my Delphi host application?

Thanks in advance for the help.

Your .NET interface must descend from IHYCrossPlatformInterface, and must have a Guid attribute; otherwise that tool won’t import it.

Look at Delphi WPF sample:

  public interface IVisualizerControl : IHYCrossPlatformInterface
        bool BarsVisible { get; set; }
        void Randomize();
        void Sinus(Double aRange);

  public class VisualizerWrapper : VisualPluginWrapper, IVisualizerControl


Let’s go step by step:

I have a VM with VS 2013 and RAD Studio XE 2 and a freshly installed Hydra

1.1.Create a new project using provided C# template “Plugin Module”
1.2.Add a new non-visual plugin using the ‘Add New Item’ menu, set its name to SomePlugin
1.3.Add a new interface to the project:

using System.Runtime.InteropServices;
using RemObjects.Hydra.CrossPlatform;

namespace TestPlugin
    public interface ISomePlugin : IHYCrossPlatformInterface
        void Foo();
        string Bar(int value);

Guid was generated via Visual Studio’s Tools menu
1.4.Implement this interface in the class added at step (1.2),
1.5.Set RemObjects.Hydra reference’s property Copy Local to true
1.4.Build the plugin

2.Host app
2.1.Create a new Delphi app using template ‘RemObjects Hydra’ -> ‘Host Application’ as described here
2.2. Then execute menu command ‘Hydra’ -> ‘Import Interfaces from .NET Assemblies’
2.3. Select assembly built at step 1.4
2.4. Import the ISomePlugin interface
2.5. Open the MainForm again
2.6. Add handlers for the event OnCreate and OnDestroy (you’ll have to change the path to the plugin dll):

  TMainForm = class(TForm)
    HYModuleManager1: THYModuleManager;
    procedure FormCreate(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    { Private declarations }
    fPlugin: IHYNonVisualPlugin;
    { Public declarations }

  MainForm: TMainForm;


{$R *.dfm}

procedure TMainForm.FormCreate(Sender: TObject);
  self.HYModuleManager1.CreateNonVisualPlugin('TestPlugin.SomePlugin', fPlugin);

procedure TMainForm.FormDestroy(Sender: TObject);


2.7.Add a button to the main form and handle its OnClick event:

procedure TMainForm.Button1Click(Sender: TObject);
  with fPlugin as ISomePlugin do begin
    MessageDlg(Bar(42),mtCustom, [mbOk], 0);

Run the host app, press the button and it will execute 2 methods of your .NET plugin


Thank you for the step-by-step tutorial. I actually got a working example exactly this way yesterday using VS 2010, Delphi XE3, and Aspose.Slides for .NET. I’m not that familiar with .NET, so it took a while and this tutorial is what I was looking for. I do think the Hydra documentation is really good. For your second code snippet, I assume you meant to show an implemented class, not a repeat of the interface?

Yes, my bad. Still there is no complex implementation needed, just any code that does something with the provided number (f.e. doubles it). The main goal of the implementation code is to show that the .NET side actually received the data and was able to send some data back to the Delphi host.