Visual Studio imported interface problems

As before: Registered Hydra 6.7.0.1345, Delphi 11, Visual Studio 2022 17.12.4

.NET8 with a test project created from the VS2022 wizard. Non visual plugin only

I have imported a Delphi interface to VS2022 in a Framework project, then copied the imported .cs to the .Net8 project, but there seem to be some problems. First off the import:

// Imported cross-patform Hydra plugin interfaces
// Some interfaces may not be imported or imported incorrectly due to the following issues:
// [51:8] CloseRound expected
//

namespace HydraTest
{
[System.Runtime.InteropServices.GuidAttribute(“d372b43d-a36a-48f2-81f4-90e5008b74aa”)]
public interface IPointCloudFilterInterface : RemObjects.Hydra.CrossPlatform.IHYCrossPlatformInterface
{
Integer TestValue();
}
}

I did some searching here but can’t figure out what the CloseRound expected message means. (During a later import while writing this message, the comment with CloseRound went away).

FYI, the comment has a a typo and says cross-patform instead of cross-platform.

Second, on Integer TestValue() Integer is unknown. I’m guess there needs to be a using, but alt-enter on Integer doesn’t give me any choices beyond creating my own type. I worked around it for now by changing it to int.

Where I’m stuck right now is I have a test C# library with the Delphi import unit in it, and I’ve created a new plugin in that library, but the Mixed Mode C# sample doesn’t show (or I can’t find where it does) how to reference the interface the import created from Delphi with the plugin, or how to create an instance of it so I can use it.

Can you give me or point me to a simple example of instancing a Delphi non-visual plugin in C#?

Hi,

can you show your delphi interface, pls?

[System.Runtime.InteropServices.GuidAttribute("d372b43d-a36a-48f2-81f4-90e5008b74aa")]
public interface IPointCloudFilterInterface : RemObjects.Hydra.CrossPlatform.IHYCrossPlatformInterface
{
    int TestValue();
}

}

I mean original delphi interface (.pas file).

PCFInterfaces.pas (273 Bytes)
NonVisualPlugin.pas (1.7 KB)
hcNPL2Controller.pas (2.2 KB)

Hi,

I can’t reproduce this error

I’ll review why it uses Integer instead of int type.
we have table that describes Delphi and .NET types at Passing Interfaces between Host and Plugins .

review this sample: testcase.zip (19.7 KB)

I’ve made some progress, through searching the forums here, but I had to make changes for it to run and I’m not getting the response I should. Maybe you can assist:

public static class Program
{
    [STAThread]
    public static void Main(string[] args_)
    {
        var moduleManager = new ModuleManager();
        var module = moduleManager.LoadModule(@"c:\temp\NPL2\Win32\Debug\NPL2.DLL");

        var plugIns = moduleManager.Plugins.ToArray();
        foreach (var plugin in plugIns)
        {
            Console.WriteLine($"{plugin.Description} {plugin.Name} {plugin.UserData}");
        }

        var inst = moduleManager.CreateInstance("PointCloudFilterInterfaceTest");

        if (inst is IPointCloudFilterInterface test)
        {
            Console.WriteLine($"{test.TestValue()}");
        }
    }
}

To make it work (and maybe it’s the cause of the wrong value), I had to change the Delphi side interface to inherit from IHYCrossPlatformPlugin instead of IHYCrossPlatformInterface.

TestValue() should return 42, it’s hard coded in Delphi, but I’m getting zero.

Hi,

these declarations work as expected:

  IPointCloudFilterInterface  = interface(IHYCrossPlatformInterface)
  ['{D372B43D-A36A-48F2-81F4-90E5008B74AA}']
    function TestValue : Integer; safecall;
  end;
    [System.Runtime.InteropServices.GuidAttribute("d372b43d-a36a-48f2-81f4-90e5008b74aa")]
    public interface IPointCloudFilterInterface : RemObjects.Hydra.CrossPlatform.IHYCrossPlatformInterface
    {
        int TestValue();
    }

testcase2.zip (19.4 KB)