I'm working on a WPF software, using .NET 9 and a custom C/C++ DLL, which is responsible for creating a Java virtual machine, using JDK 17 with JNI version 1.8 or 10.
I already got that working on a pure C/C++, with GLFW, executable program.
The main problem is: As pointed on several articles (For instance: Exception 0xC0000005 from JNI_CreateJavaVM (jvm.dll)) the "0xC0000005: Access violation reading location 0x00000000" exception is expected.
On the pure C/C++ executable problem I simply ignore the exception and the program continues normally.
But, for mad reasons, when using the LibraryImport attribute to call my custom DLL OR when calling the jvm.dll directly from C# and trying to create the JVM using 'Marshaling', I cannot ignore the error and the application crashes.
On C/C++ side I already tried using jvm as library (jvm.lib) and with the dynamic DLL loader (LoadLibrary("path\to\jvm.dll")). Both ended with same results.
Is there anything I'm missing or some workaround?