C ++ DLL无法找到C#dll及其在java中的依赖性 [英] C++ dll cant locate C# dll and its dependacy in java

查看:76
本文介绍了C ++ DLL无法找到C#dll及其在java中的依赖性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个使用外部dll作为参考的C#项目。然后我创建了一个C ++程序,它将C#生成的dll添加为引用,这样我就可以从c ++调用C#函数然后使用java jni方法调用。当我在visual studio中编译应用程序时,它会生成cpp dll。但是当我从java调用cpp dll时,jvm崩溃,因为cpp dll找不到C#dll引用。我的问题是我如何配置C ++项目,以便将所有C#dll及其依赖性合并为一个,以便使用jni从java调用C#项目中的函数成功?

I have created a C# project that uses a external dll as reference. I have then created a C++ program that add the C# generated dll as reference, so that I can Invoke the C# function from c++ and then use java jni method call. When I compile the application within visual studio it generate the cpp dll fine. But when I call the cpp dll from java the jvm crashes as the cpp dll cant find the C# dll reference. My question is how can I configure the C++ project so that it combines all the C# dll and its dependancy into one so that call the functions from the C# project from java using jni is successfull?

推荐答案

您需要从C ++加载C#。以下是动态加载的文章。



内部问题是,Java,C ++和C#都有自己的运行时环境,因此您需要在项目中运行3个必须进行交互的运行时。我想它会很慢而且糟糕。



BTW:我建议不要使用JNI的C#,而是用C ++包装所有。另外:考虑将C#逻辑移动到Java,
You need to load the C# from C++. Here is an article of the Dynamic Loading.

The internal problem is, that Java, C++ and C# have own runtime environments, so you need in the project 3 runtimes which must interact. I guess it will be slow and crappy.

BTW: I would recommand NOT using C# from JNI, but wrapping all in C++. Alternativly: think about moving the C# logic to Java,


这篇关于C ++ DLL无法找到C#dll及其在java中的依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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