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

时间:2013-02-13 12:27:30

标签: c# java mono java-native-interface ikvm

我们正在使用IKVM将我们的* .jar转换为我们使用Mono将代码迁移到C#的dll。 我们遇到一个问题,特别是在使用jar包含JNI调用时,浏览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)

作者的回应:

>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).

正如您所看到的,作者在没有给我们解决方案的情况下回答了几句话。

我所理解的是嵌入式Dll会产生错误,实际上IKVM不知道如何使用它(在JAR内部)......

有一些建议可以解决这个问题吗? PS:什么意思是Fixed in cvs? 谢谢。

1 个答案:

答案 0 :(得分:0)

问题的原因是您没有输出位置的写权限。在具有写权限的其他位置上运行该命令。

我认为该修复只会阻止“内部编译器错误”消息。