Using dlls written in C# in Java Project
I'm working on a Java project and I'm not very familiar with using Java I usually use C# with aforge for my computer vision projects now I have to use Java and I want to use the开发者_如何学Python aforge DLLs which are written in C# is there a way to do this ?
Thank you
It is possible, but you'll need to do some work to get them calling properly. I've never done it myself, but until someone better equipped to answer the question comes along here's a few places to start.
Take a look at the JNI (Java Native Interface, google or wikipedia can tell you more), which lets you call out from Java to other languages. There seems to be a project called jni4net ( http://jni4net.sourceforge.net ) which is intended to do exactly what you want, but it's in alpha at the moment and might not be stable enough. Still it could be worth having a look.
You can also do it yourself, calling through the JNI as a C call which will then get through to the CLR eventually, but it looks like a lot of effort. I know this isn't a quick and easy solution, but it might give you a couple of places to get started. also http://www.codeproject.com/KB/cross-platform/javacsharp.aspx seemed to be a fairly good look at how to go about it.
As all of the other answers so far have said though, it's fiddly and a pain. If you can do something else instead, it will probably be worth it.
Have a look at Jni4Net and this stack overflow question: is there an effective tool to convert c# to java?
You would have to use native calls which would a) be really irritating to keep up to date and B) defeat the huge advantage of java being cross-platform.
Your best bet might be to try to find something that can convert C# to java--or better yet recode your C# code into java.
In the long run it will save you a lot of stress.
No sure about this possibility but your idea is not so good. You still can use COM or hook or try ngen but this ways all are weird.
Java is very similar C# . Try to code in Java or something like stab , I think that is much easer to code in some JVM-based langue for jvm.
Diferent compilers dud, it's not possible. Unless You use java sharp language in visual studio, then the compilers mach.
精彩评论