Search code examples
c#dllikvm

How to call a dll file from c#


I am trying to call a dll file from c#

The dll file is made from a java application using ikvm and for now all the code does is print hello world.

How do i call the dll file in my c# code and is it possible to create an application in java that will return a boolean value to my c# code?

Thanks for your time.


Solution

  • I'm not sure I understand what you're trying to do, so apologies if I'm misreading. IKVM should translate your java code to a .NET dll or executable. After the "translation" you should be able to use the .dll more or less in the same way as you would with a "native" .NET code.

    If your java application has a main method that prints "hello world" on the console, you should have converted it to a .NET executable (.exe) and not to a dll. After converting it to a .exe (and assuming you're running it on Microsoft .NET on a windows system) you should just execute it.

    As for the second part of your question, you can also create a dll (converted from java) that returns a boolean and consume it from a C# application.

    See this tutorial for two examples of (pretty much exactly) what you're doing.