Call .NET DLL from Java

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

The flow is as follows.

  • A .net DLL was created using a C # class library type project from visual studio 2010.

  • Own C ++ code (console application) for using this DLL was created. Using this walkthrough from Microsoft. This code allows you to successfully call DLL code.

  • I wrote Java code with some of my own methods, generated headers and implemented the header in the C ++ DLL project (transferred the source code from the example to the corresponding methods, made some variables global).

This DLL loaded successfully, but the code does not work when creating the interface pointer for the managed class.

see snipper from microsoft manual

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

Note that this call returns successfully for the console application, but on the call, although the JNI thread, the JVM crashes.

+4
source share
1 answer

My java code worked in a 64-bit JVM, replaced with a 32-bit JVM and it no longer crashes.

+1
source

Source: https://habr.com/ru/post/1385927/


All Articles