简体   繁体   中英

Calling .NET DLL from Java

I am trying to use a .NET DLL from Java code ( Through a C++ native code).

Flow is like this.

  1. Created .net DLL using C# class library type project from visual studio 2010.

  2. Created native C++ code (Console application) to use this DLL Using this step-by-step guide from Microsoft This code is able to successfully calls DLL code.

  3. Wrote Java code with some native methods, generated headers and implemented header in C++ DLL project(moved original code from example in relevant methods,made some variables global).

This DLL is loaded successfully, but the code fails while creating Interface pointer for Managed class.

see snipper from microsoft guide

 // Create the interface pointer.
ICalculatorPtr pICalc(__uuidof(ManagedClass));

Please note this call returns successfully for console application, but when called though JNI flow, JVM crashes.

我的java代码在64位JVM中运行,替换为32位,并且没有更多的JVM崩溃。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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