Skip to content

Can i pass array with jna to .net? #30

Closed
@K-Full

Description

@K-Full

I am sorry about all the questions. I do not know well if you search on Google, so please let me know.
Can I pass an array from JNA to .net using UnmanagedExports?

Here is my code

//java
int arr = new int[2];
arr[0] = 1;
arr[1] = 2;
test(arr);

//JNA
public interface VbWrapper extends Library {
public int test(int[] intArr);
}

//.net
<DllExport("test", CallingConvention.StdCall)>
Function test(ByVal arr() As Integer) As Integer
MsgBox(arr.length) ' printed 1
MsgBox(arr(1)) ' invalid memory access 

Am I making a mistake?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions