I have a C# DLL that needs to be called from a Java application.
I suspect that this can't be done directly, but perhaps through a JNI wrapper to a C++ DLL which in turn calls the C# DLL
I am looking for an answer that provides the simplest of examples that I can compile and test.
(e.g. a C# class with a simple method that inputs one string and returns another....and those inputs and outputs are passed down and up through the layers).
Do we need COM involved in this If so, how

Calling C# DLL from a Java application (or even another C++ or VB app)
Purusothaman A
There is JNI Library for .NET that makes possible to write managed JNI code in any language (MCpp, C#, J#, VB) without interops:
http://www.simtel.net/product.php[id]95126[sekid]0[SiteID]simtel.net
http://www.simtel.net/product.php[id]98653[SiteID]simtel.net
Both packages include examples in all .NET languages.
Bwilhite
Search code project for "Call Managed Code". Code Project has 2-3 articles on this. And if you have Professional C# Book bye Wrox Publishers, that also have examples of the same thing in VB, C++.
This question was already answered with the links but I dont want to find tht now. Its easy to find code project your self and I thikn this forum has also many posts related to the same thing + Google is the Best "Call Managed Code from Unmanaged Code"
I hope this will help.
Best Regards,
Catalin Zima
You can also test Add-In for VS2003, which generates Java wrappers in managed JNI code (MCpp, C#, J#, VB) and in unmanaged JNI code (C++):
Tomerico
Thanks vitallis...
I'll need to look into these a bit more, but really appreciate the suggestions...
Cheers~!
Ultrawhack
Hi there,
I am trying to do the same....
Have you found any solution for this... any code sample will be helpful.
Cheers!
Yairt
Unexpected issue...
I got this working useing the links you provided. At least, when I compiled in Debug mode. But when I switched to Release mode I got errors during the compile:
"D8016" /clr and /mt are incompatible (etc.)
I am using VS2005 and it seems like some things have changed with respect to the "clr" compile switch. It's frustrating because it works when compiled in debug mode. I have tried everything to resolve the compatibility issue, but it seems like VS2005 just overrides the options at run time and forces "/mt" on me (even though I change it to "/md"). "clr" is required and nothing works when I turn that off.
So where do I go from here I'm trying it now in VS2003 but seem to be hitting a different issue: unresolved link... I'll need to look more into that.
Maybe there's another way to do this that is compatible with the newer versions of Visual Studio
donkaiser
Sorry for the late response...
I'm afraid I didn't get much further than this. I ended up moving on to something else, but will definitely return back to this area at some point. If I do, I'll be sure to try and post something helpful ;-)