简体   繁体   English

如何将包含本机调用的* .jar转换为DLL(Mono C#)

[英]How to convert *.jar that contains native call to a DLL(Mono C#)

We're using IKVM to convert our *.jar to dll that we using to migrate our code to C# with Mono.. We have a problem especially when working with jar contains a JNI call, expl JnativeHook , its make an error when we try to convert it using IKVM, i have reported the error to the author as the follow: 我们正在使用IKVM将* .jar转换为dll,以便使用Mono将代码迁移到C#。我们遇到了一个问题,尤其是在使用jar包含JNI调用expl JnativeHook时,尝试时会出错要使用IKVM进行转换,我已将错误报告给作者,如下所示:

I'm trying to use JnativeHook.jar library, its work for my java apllications, However:
 Not: JnativeHook its a cross-platform containes  3 .dll  depends on the OS when the java application is running (dynamic loading of *.dll)...
JnativeHook.jar containes also  a package(demo) that containes a main classe, i have solved this problem by deleting this one, now i'm sure that will be converted to dll...
finally, when i try to convert this one to .dll i get this error:

C:\Users\marwen\Desktop\Kid protector\Tools and IDE\ikvmbin-7.2.4630.5\bin>ikvmc JNativeHook.jar
IKVM.NET Compiler version 7.2.4630.5
Copyright (C) 2002-2012 Jeroen Frijters
http://www.ikvm.net/

note IKVMC0002: Output file is "JNativeHook.dll"

*** INTERNAL COMPILER ERROR ***

PLEASE FILE A BUG REPORT FOR IKVM.NET WHEN YOU SEE THIS MESSAGE

System.UnauthorizedAccessException: L'accès au chemin d'accès 'C:\Users\marwen\Desktop\Kid protector\Tools and IDE\ikvmbin-7.2.4630.5\bin\JNativeHook.dll' est refusé.
   à System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   à System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, Str
ing msgPath, Boolean bFromProxy)
   à System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   à System.IO.FileStream..ctor(String path, FileMode mode)
   à IKVM.Reflection.Writer.ModuleWriter.WriteModule(StrongNameKeyPair keyPair, Byte[] publicKey, ModuleBuilder moduleBuilder, PEFileKinds fileKind, PortableExecutableKinds portableExecutableKind, Ima
geFileMachine imageFileMachine, ResourceSection resources, Int32 entryPointToken, Stream stream)
   à IKVM.Reflection.Emit.AssemblyBuilder.SaveImpl(String assemblyFileName, Stream streamOrNull, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
   à IKVM.Reflection.Emit.AssemblyBuilder.Save(String assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
   à IKVM.Internal.CompilerClassLoader.Save()
   à IKVM.Internal.CompilerClassLoader.Compile(String runtimeAssembly, List`1 optionsList)
   à IkvmcCompiler.Compile(String[] args)
   à IkvmcCompiler.Main(String[] args)

The response from the author: 作者的回应:

>Comment By: Jeroen Frijters (jfrijters)
Date: 2013-02-12 03:28

Message:
Thanks. Fixed in cvs. BTW, the error is because ikvmc can't write to
JNativeHook.dll (probably because you don't have write access to the
directory).

As you can see the author has respond with a few words without giving us a solution.. 如您所见,作者仅用几句话就回答了,但没有给我们解决方案。

What i understand is the embedded Dll make the error, in fact IKVM does not know how to work with it(inside the JAR)... 我了解的是嵌入式Dll产生了错误,实际上IKVM不知道如何使用它(在JAR内部)...

there is some suggestions to solve this problem? 有解决此问题的建议吗? PS: what does mean Fixed in cvs ? PS: Fixed in cvs什么意思? Thank you. 谢谢。

The cause of the problem is that you have no write rights to the output location. 问题的原因是您没有对输出位置的写权限。 Run the command on another location with write rights. 在具有写权限的其他位置上运行命令。

I think the fix will only prevent the "INTERNAL COMPILER ERROR" message. 我认为此修复程序只会阻止“内部编译器错误”消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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