简体   繁体   English

可以使用在vb.net或Java中的c#中创建的库?

[英]can use a library created in vb.net or c# in java?

I have written some classes in C# and compiled it. 我已经用C#编写了一些类并进行了编译。 Now I have the library file for these classes. 现在,我有了这些类的库文件。 Can I use the same dll with Java? 我可以在Java中使用相同的dll吗?

I do not want to write it in Java once again because I am writing the same program in different languages (trying to do so). 我不想再次用Java编写它,因为我正在用不同的语言编写相同的程序(试图这样做)。

So I am making the classes to a library file and want to use it in all the programing languages. 因此,我正在将类制作为库文件,并希望在所有编程语言中使用它。

Java normally uses a completely different runtime (inside the JVM). Java通常使用完全不同的运行时(在JVM内部)。 There are tools intending to help bridge the gap ( IKVM leaps to mind), but in general : no, you can't do this. 一些工具可以帮助弥合差距( IKVM值得一提),但总的来说 :不,您不能这样做。 Of course, you can use IPC etc to talk between them, but they are not best friends. 当然,您可以使用IPC等他们之间进行交谈,但是他们不是最好的朋友。

You need to searialize your code into byte, xml or json. 您需要将代码重新编码为字节,xml或json。 so you can use your codes in another language 因此您可以使用其他语言的代码

One area you can look into is JNI (Java Native Interface), see http://en.wikipedia.org/wiki/Java_Native_Interface as a starting point. 您可以研究的一个领域是JNI(Java本机接口),请参阅http://en.wikipedia.org/wiki/Java_Native_Interface作为起点。 There are possibly easier to use bridges for .NET to Java, ah here we go, see Calling C# code from Java? NET到Java的桥梁可能更容易使用,啊,我们走了,请参阅从Java调用C#代码?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM