3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
937 stars 131 forks source link

Passing Arrays & Object between Java and C# #187

Closed namhvcntt closed 3 years ago

namhvcntt commented 3 years ago

I'm trying to pass data between Java and C#, it works with primitive data types but not work with Array and Object. I watched 2 demos but they are not mentioned how to pass array and object. Can you help me to provide some instructions? Thanks.

Here is my some code C# code

{
        [DllExport]
        public static String[] getAvailablePorts() {
            return System.IO.Ports.SerialPort.GetPortNames();
        }
}

Java & JNA code

public class Demo{
    static {
        Native.register("<path_to_dll>");
    }
    public native static String[] getAvailablePorts();
}
3F commented 3 years ago

Duplicate of #30

I watched 2 demos but they are not mentioned how to pass array and object.

I think it was mentioned if you're talking about screencasts

https://github.com/3F/DllExport/wiki/Examples-Part-2

08:42 - Passing arrays from unmanaged C++ ((host side)) to C#. 12:27 - Passing multidimensional arrays from C++ ((host side)) to C#. 22:47 - Passing arrays to C# from Java ((host side)).

structures

05:21 - Passing complex types from C# to unmanaged C++ ((host side)). Samples for structures. 16:23 - Passing complex types from C++ to C# ((host side)). Samples for structures.

in advance, my note about dotnet classes