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

本文关键字:转换 DLL MonoC# jar 包含本 调用 | 更新日期: 2023-09-27 17:58:52

我们使用IKVM将*.jar转换为dll,我们使用该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)

作者的回复:

>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?非常感谢。

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

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

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