从Java调用VB.NET函数的最佳方法? [英] Best way to call VB.NET function from Java?

查看:188
本文介绍了从Java调用VB.NET函数的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在作为公司的软件开发人员进行实习。有一个客户端安装的软件程序,用C#编写,在VB中都有dll,无论是在.NET框架上。我们的整个基于云的服务器是用Java编写的,所以现在 ,我的任务只是在Java中调用一个获取/设置私有的函数(对不起,不太熟悉VB,所以我可能使用这个术语不适当)位于dll内的变量。最终,尽管如此,我的任务是从客户端程序中收集数据并将其放在我们的服务器中。我在过去几天一直在研究如何做这个事情,并找到了几个选项:




  • Java本机访问)

  • Java本机接口(JNI)

  • COM / ActiveX桥接(虽然我不能完全说出我知道这些是/如何使用它们_

  • JNBridge



现在据我所知,这些都是问题我分别找到:




  • 使用此选项需要使用C或C ++从Java到.NET的中介,并给出我只是真的知道Java,我不想在这个混乱中纠结。

  • 似乎比JNA更复杂一些,我觉得它没有真正的优势无论如何,他们似乎都需要一个C / C ++中介。

  • ...除了我不太确定我可以如何关于实现这种方法。

  • 这个和其他类似的b山脊必须是最后的手段。该产品的开发许可证相当昂贵,我确信他们没有资源使用本产品。我可以试着问,但我真的不认为这是一个实习生的地方,要求一家公司投资太多。



为了增加一个事实,我不是那么擅长编程,所以我主要是为了自己这么做,所以非常感谢提前阅读我的问题。如果有一些我还没有完全解释,需要进一步解释,请让我知道!

解决方案

我可以建议JNA与 UnmanagedExports ,因为它只需要C#,VB.NET或F#.dll与以下标题



C#:

  [RGiesecke.DllExport.DllExport] 
public static String yourFunction(String yourParameter)
{
returnCSharp String;
}

之后,您可以像JNA一样使用任何其他C或C ++ .dll在Java中。你可以在这个类似的问题中找到一个例子和一些我在答案中无法解决的限制:使用JNA从Java调用DLL



我只用C#尝试过,但如 documentation 它应该与C#,F#和VB.NET一起使用。


I'm interning as a software developer for a company. There is a client-installed software program written in C# that has dll's in VB - both on the .NET framework. Our entire cloud-based server is written in Java, so for now, my task is simply to call a function in Java that gets/sets a private(? sorry, not really familiar with VB so I might be using this term inappropriately) variable located within the dll. Ultimately, though, my task will be to collect data from the client program and put it in our server. I've been researching how to go about doing this for the past few days and have found a few options:

  • Java Native Access (JNA)
  • Java Native Interface (JNI)
  • COM/ActiveX bridges (though I can't entirely say for sure that I know what these are/how to use them_
  • JNBridge

Now as far as I know, these are the issues I've found with each, respectively:

  • Using this option requires an intermediary from Java to .NET using either C or C++, and given that I only really know Java, I'd not really like to get tangled in this mess.
  • Seems a tad bit more complicated than JNA, and I think it has no real advantages over JNA anyways. They both appear to have the need of a C/C++ intermediary.
  • ... can't really say much aside from the fact that I'm not really sure how I can go about implementing this method.
  • This and other similar bridges has to be a last resort. The developer license for this product is quite pricey, and I'm sure they we don't have the resource to use this product. I could try asking, but I don't really think it's in the place of an intern to ask that a company invest so much.

To add to the fact that I'm not really that adept in programming, I've been left to mostly do this on my own so thanks so much in advance for reading my question. If there's something I haven't fully explained that necessitates further explanation, please let me know! Any other tips/pointers would be immensely appreciated.

解决方案

I can recommand JNA together with UnmanagedExports since it requires only C#, VB.NET or F# .dll with the following Header

C#:

[RGiesecke.DllExport.DllExport]
public static String yourFunction(String yourParameter)
{
    return "CSharp String";
}

after that you can consume it with JNA like any other C or C++ .dll in Java. You can find an example and some restrictions I couldn't come around in my answer at this similar question: Call DLL from Java using JNA

I only tried it with C#, but as stated in the docu it should work with C#, F# and VB.NET.

这篇关于从Java调用VB.NET函数的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆