I've converted a java library succesfully with ikvmc. Java library uses some resources inside its self jar file. I can reach all classes of this java library, but if I call a method that calls this.getClass().getResource(), it doens't search these resources in the assembly or the jar file in the assembly. But if I put these resources to same folder with the assembly, it can find the resources. But it doesn't work well everytime. For instance, it can't find the resources if I referenced the assembly in a website project(mvc). I tried to put these resources to bin folder, root folder, the view's folder, etc.(see my comment on this post)
So I need a permanent solution. The java library is an open source project. But I don't want to change the sources. Because the compiling the project needs eclipse, ant, 3rd party libs, etc. Also in the next release of the java library, I'll have to change the code and compile it.
I saw "resource" paramter of ikvmc. But I couldn't find a documentation or an example for this.
Now I'll try to implement a .net class that derived from the java class that calls getResource method. And then I'll overide the method that calls getResource method. But this isn't a permanent solution too.
相关问题
- Generic Generics in Managed C++
- How to Debug/Register a Permanent WMI Event Which
- 'System.Threading.ThreadAbortException' in
- Bulk update SQL Server C#
- Should I use static function in c# where many call
I've found the solution. Actually I've found where I did wrong. First I had converted java library like this:
Then I had merged all these dlls with ILMerge. The problem wasn't in merging the dlls. The problem was in loading the resorces. The loader function is in main library. And the second and the third libraries use this loader function from main library. So the loader function searches for only its jar file that is first.jar. it doesn't search the other jars even if all of them is in the same merged dll. So I changed my convert script like this:
So, all jars merged with this one line of command. Although I don't have to use ILMerge anymore. There isn't any explanation about "sharedclassloader" in ikvmc help page. I found this explanation in this page.