tags:

views:

211

answers:

6

Can you give me some pointers on making C# code and Java code interoperate? Let's define the interoperation as something simple: allow (from Java code) the instantiantion and method calling of a class defined in C#, and, possibly, the other way around as well.

Is this even possible natively? (i.e. without some proxy/skeleton interface mechanism)

And finally, what proxy mechanisms can be used? (i.e. are supported by both language realms)

+6  A: 

I've used IKVM to accomplish this successfully.

Ben Hoffstein
+1  A: 

I've found a very promising article on CodeProject here.

Excerpt from the article introduction:

The suggested solution will show how the two frameworks can live together in the same process and communicate seamlessly with each other.

This article describes a high-performing interoperability solution between the Java platform and the .NET Framework. The suggested solution does not replace the Java Virtual Machine or the .NET Framework runtime, instead, your JVM or .NET are each hosted within the opposing runtime environment, ensuring that vendor-specific VM optimizations are preserved.

Cristi Diaconescu
A: 

There are a few third-party products that can do .NET-Java interop natively. J-Integra is the one I'm most familiar with (I don't work for them nor do I have any economic interest in them).

If you're ok with proxies and the like, you have a few options like SOAP/Web Services or CORBA.

James Schek
+1  A: 

Don't know what needs to be done on the .NET side (I'm not a .NET guy), but Java provides the JNI framework for interoperating with native libraries.

Start with Wikipedia, then follow the links...

ykaganovich
A: 

I am author of jni4net, open source interprocess bridge between JVM and CLR. It's build on top of JNI and PInvoke. No C/C++ code needed. I hope it will help you.

Pavel Savara