简体   繁体   中英

Problems with using a dll in a JNI-created dll

I am working on a Java project in which I have to use a third party dll (let's say abc.dll). So I created a native header file using JNI.

Then I created a dll project on vs2005 (typical win32 app.) and added that header file created by JNI. I selected clr old syntax support for the project and added the abc.dll as a reference to my project.

Up to now, everything is ok. Here is the problem. I implemented the methods defined in the header file using some methods from the abc.dll. abc.dll has a class called "abc" and that's what I do:

abc *abcObj = new abc(); abcObj->callSomeMethod();

I take a build from the solution, everything is ok. But when I run my Java program, I get an error from the JVM telling that native code broke down?!?! I debugged it and the problem is in new(). It simply cannot instantiate the abcObj.

Then I tried with a c++ app using that abc.dll. It worked.

I think there must be problem with JNI or that managed/unmanaged thing. I am not really experienced at c/c++ so I don't understand so much (at least I don't have time to understand for now). Only thing I try to do is create a wrapper dll using the third party dll and use the wrapper dll in my java app.

Any help will be appreciated.

Thanks in advance...

-haydar

edit: I have all the dlls that are needed by my third party dll.

I have solved the problem. The problem was that I was creating the project as a win32 application and choosing dll then. I created a clr application and everything went well. I followed the instructions from here .

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