I have one DLL
( TransferImg.dll
) that is written in C#
(provided by an external company), which they tell me that I need to create an interface to access image transmission functions from JAVA, I have been investigating how, but I have not found something that understands or works.
The data provided to me is: - TransferImg.dll library
- Add reference to project.
- Add Using Transfer
;
- Create Object Command myobj = new Command();
- Call the function myobj.SendImagesToScale
which returns an integer with the error.
This is the function I want to use:
int SendImagesToScale(string Ip, string PathImage ,string Tipo, Socket iSock);
I don't have a clear idea how to do it, this is my code taken from an example:
public class SendImg {
public interface CLibrary extends Library {
CLibrary INSTANCE = (CLibrary)
Native.loadLibrary((Platform.isWindows() ? "C:\TransferImg.dll" : "c#"), CLibrary.class);
void SendImagesToScale(string Ip, string PathImage ,string Tipo, Socket iSock);
}
public static void main(String[] args) {
CLibrary.INSTANCE.SendImagesToScale("192.168.1.111", "C:\img.jpg", "Splash", 3306);
}
}
Dll: TransferImg.dll
I just created a test project in c# and added the DLL you uploaded to the created project.
And when inspecting the dll the function does not exist
int SendImagesToScale(string Ip, string PathImage ,string Tipo, Socket iSock);
as such but there is a similar one that is this:int TORREYSendImagesToScale(String sIpScale, String sPathImage, String sTypeData, Socket iSock);
The problem is that if you want to use it you cannot do it directly since this is a function of a class and the function is not declared as static so you must first create an instance of the class and then call the function through the created instance .
Check the dll and I didn't find any function
void SendImagesToScale(string Ip, string PathImage ,string Tipo, Socket iSock);
but if there is oneint TORREYSendImagesToScale(String sIpScale, String sPathImage, String sTypeData, Socket iSock);
that may be your mistake, decompile the dll with dotpeek ( https://www.jetbrains.com/decompiler/download/ ) so you can study the dll more or go back to do it to your liking, well that way I could see all the code inside the dll, in the namespace of TorreyTransfer is the functionTORREYSendImagesToScale
.I made a bit of code that could help you:
Where
TransferImg.dll
it should be in the address of your project.You need to make several wrappers, call a class that calls a class that calls your
DLL
enC#
, an example is:Here you have a page that could be of great help: LINK