Search code examples
javac#jna

Error looking up for: '' The specified procedure could not be found


I am trying to use C# dll function in java. I got the error that function cannot be found, however, the dll was found and successfully loaded.

While I was searching for a problem I found that sometimes a compiler mangle the symbols and the whole function name to something like 'myFunction@32' instead of 'myFunction'. Unfortunately that wasn't my issue.

public interface IConectorT extends Library {
boolean DeleteCustomObjectRecord(String company, String username, String password, int cdoId, 
String cdoName, int[] cdoRecordIds);


IConectorT INSTANCE = (IConectorT) Native.loadLibrary("C:\\Windows\\System32\\Eloqua API", 
IConectorT.class, new HashMap() {
    {
        put("DeleteCustomObjectRecord","_DeleteCustomObjectRecord@32");
    }
});
}

I have tried @64, @32, @16 etc. Also tried adding "_" as prefix. I have also tried absolute path with ".dll" and without, relative path the same. (But loading is not a problem)

I tried a little update and now it returns this error:

Exception in thread "main" java.lang.UnsatisfiedLinkError: 
Main.Main.DeleteCustomObjectRecord(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;ILjava
/lang/String;[I)Z
at Main.Main.DeleteCustomObjectRecord(Native Method)
at Main.Main.main(Main.java:15)

Solution

  • As far as I know, JNA is for native library only. You will need to write a C/C++ wrapper for your C# library before accessing it from Java.

    Check this answer