C#调用java包,报错:“java.lang.StdIO”的类型初始值设定项引发异常

GGL123 2017-12-10 05:30:04
求救:
我在C#里调用java包,
引用到:
IKVM.OpenJDK.Core.dll
IKVM.Runtime.dll
IKVM.Runtime.JNI.dll
还有一个打包好的java包:WsRequestDemo.dll

但是在使用时跳出错误:“java.lang.StdIO”的类型初始值设定项引发异常

具体为:
未处理 System.TypeInitializationException
Message="“java.lang.StdIO”的类型初始值设定项引发异常。"
Source="IKVM.OpenJDK.Core"
TypeName="java.lang.StdIO"
StackTrace:
在 java.lang.System.get_out()
在 java.lang.Class$3.run()
在 java.lang.Class$3.run()
在 java.security.AccessController.doPrivileged(Object , AccessControlContext , CallerID )
在 java.security.AccessController.doPrivileged(PrivilegedAction action, CallerID )
在 java.lang.Class.checkInitted()
在 java.lang.Class.privateGetDeclaredConstructors(Boolean )
在 java.lang.Class.getConstructor0(Class[] , Int32 )
在 java.lang.Class.newInstance0(CallerID )
在 java.lang.Class.newInstance(CallerID )
在 sun.security.jca.ProviderConfig$2.run()
在 sun.security.jca.ProviderConfig$2.run()
在 java.security.AccessController.doPrivileged(Object , AccessControlContext , CallerID )
在 java.security.AccessController.doPrivileged(PrivilegedAction action, CallerID )
在 sun.security.jca.ProviderConfig.doLoadProvider()
在 sun.security.jca.ProviderConfig.getProvider()
在 sun.security.jca.ProviderList.getProvider(Int32 )
在 sun.security.jca.ProviderList.getService(String type, String name)
在 sun.security.jca.GetInstance.getInstance(String type, Class clazz, String algorithm)
在 java.security.Security.getImpl(String , String , String )
在 java.security.MessageDigest.getInstance(String algorithm)
在 com.zht.WsRequestDemo.getMessageDigest(String str1, String str2)
在 WindowsFormsApplication1.Form1.button1_Click(Object sender, EventArgs e) 位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.cs:行号 28
在 System.Windows.Forms.Control.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnClick(EventArgs e)
在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
在 System.Windows.Forms.Button.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
在 System.Windows.Forms.Application.Run(Form mainForm)
在 WindowsFormsApplication1.Program.Main() 位置 C:\Documents and Settings\Administrator\My Documents\Visual Studio 2008\projects\WindowsFormsApplication1\WindowsFormsApplication1\Program.cs:行号 18
在 System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
在 System.Threading.ThreadHelper.ThreadStart()
InnerException: System.IO.FileNotFoundException
Message="未能加载文件或程序集“IKVM.OpenJDK.Util, Version=7.2.4630.5, Culture=neutral, PublicKeyToken=13235d27fcbfff58”或它的某一个依赖项。系统找不到指定的文件。"
Source="IKVM.OpenJDK.Core"
FileName="IKVM.OpenJDK.Util, Version=7.2.4630.5, Culture=neutral, PublicKeyToken=13235d27fcbfff58"
FusionLog="=== 预绑定状态信息 ===\r\n日志: 用户 = VSTFS\\Administrator\r\n日志: DisplayName = IKVM.OpenJDK.Util, Version=7.2.4630.5, Culture=neutral, PublicKeyToken=13235d27fcbfff58\n (Fully-specified)\r\n日志: Appbase = file:///C:/Documents and Settings/Administrator/My Documents/Visual Studio 2008/projects/WindowsFormsApplication1/WindowsFormsApplication1/bin/Debug/\r\n日志: 初始 PrivatePath = NULL\r\n调用程序集: IKVM.OpenJDK.Core, Version=7.2.4630.5, Culture=neutral, PublicKeyToken=13235d27fcbfff58。\r\n===\r\n日志: 此绑定从 default 加载上下文开始。\r\n日志: 未找到应用程序配置文件。\r\n日志: 使用 C:\\WINDOWS\\Microsoft.NET\\Framework\\v2.0.50727\\config\\machine.config 的计算机配置文件。\r\n日志: 策略后引用: IKVM.OpenJDK.Util, Version=7.2.4630.5, Culture=neutral, PublicKeyToken=13235d27fcbfff58\r\n日志: 相同的绑定已出现过,因 hr = 0x80070002 而失败。\r\n"
StackTrace:
在 sun.misc.URLClassPath.JarLoader.ensureOpen()
在 sun.misc.URLClassPath.JarLoader..ctor(URL , URLStreamHandler , HashMap )
在 sun.misc.URLClassPath$3.run()
在 sun.misc.URLClassPath$3.run()
在 java.security.AccessController.doPrivileged(Object , AccessControlContext , CallerID )
在 java.security.AccessController.doPrivileged(PrivilegedExceptionAction action, CallerID )
在 sun.misc.URLClassPath.getLoader(URL )
在 sun.misc.URLClassPath.getLoader(Int32 )
在 sun.misc.URLClassPath.access$000(URLClassPath , Int32 )
在 sun.misc.URLClassPath$1.next()
在 sun.misc.URLClassPath$1.hasMoreElements()
在 IKVM.Internal.AssemblyClassLoader.<GetResourcesImpl>d__0.MoveNext()
在 IKVM.Internal.AssemblyClassLoader.<GetResourcesImpl>d__0.MoveNext()
在 IKVM.NativeCode.ikvm.runtime.AssemblyClassLoader.getResources(ClassLoader classLoader, Assembly assembly, String name)
在 ikvm.runtime.AssemblyClassLoader.getResources(ClassLoader , Assembly , String )
在 ikvm.runtime.AssemblyClassLoader.getResources(String name)
在 java.util.ServiceLoader.LazyIterator.hasNext()
在 java.util.ServiceLoader$1.hasNext()
在 java.nio.charset.Charset$1.getNext()
在 java.nio.charset.Charset$1.hasNext()
在 java.nio.charset.Charset$2.run()
在 java.nio.charset.Charset$2.run()
在 java.security.AccessController.doPrivileged(Object , AccessControlContext , CallerID )
在 java.security.AccessController.doPrivileged(PrivilegedAction action, CallerID )
在 java.nio.charset.Charset.lookupViaProviders(String )
在 java.nio.charset.Charset.lookup2(String )
在 java.nio.charset.Charset.lookup(String )
在 java.nio.charset.Charset.defaultCharset()
在 sun.nio.cs.StreamEncoder.forOutputStreamWriter(OutputStream out, Object lock, String charsetName)
在 java.io.OutputStreamWriter..ctor(OutputStream out)
在 java.io.PrintStream..ctor(Boolean , OutputStream )
在 java.io.PrintStream..ctor(OutputStream out, Boolean autoFlush)
在 java.lang.StdIO..cctor()
InnerException:


...全文
981 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
jeffGZHU 2021-03-04
  • 打赏
  • 举报
回复
我是只引用了这几个dll就行
yunqing1201 2020-08-02
  • 打赏
  • 举报
回复
将KIVMbin中的 dll 全部拷贝到C#项目的debug中就可以了
ztmaster 2020-01-01
  • 打赏
  • 举报
回复
要引用IKVM安装文件夹下的文件:   %IKVM_HOME%\bin\IKVM.OpenJDK.Core.dll   %IKVM_HOME%\bin\IKVM.Runtime.dll   %IKVM_HOME%\bin\IKVM.Runtime.JNI.dll 引用后编译整个工程, 这样会在.Net项目的bin文件夹中生成以下dll文件: IKVM.AWT.WinForms.dll IKVM.OpenJDK.Beans.dll IKVM.OpenJDK.Charsets.dll IKVM.OpenJDK.Corba.dll IKVM.OpenJDK.Core.dll IKVM.OpenJDK.Management.dll IKVM.OpenJDK.Media.dll IKVM.OpenJDK.Misc.dll IKVM.OpenJDK.Naming.dll IKVM.OpenJDK.Remoting.dll IKVM.OpenJDK.Security.dll IKVM.OpenJDK.SwingAWT.dll IKVM.OpenJDK.Text.dll IKVM.OpenJDK.Util.dll IKVM.OpenJDK.XML.API.dll IKVM.Runtime.dll IKVM.Runtime.JNI.dll 把这些文件拷到项目里面单独的一个新建的commonLib文件夹中, 再删除原来引用的%IKVM_HOME%\bin\那三个引用, 再添加commonLib文件夹中所有的dll 重新编译生成, 应该就可以了.
XBodhi. 2019-08-06
  • 打赏
  • 举报
回复
还真么有这么操作过。推荐你用web接口吧。
smiledesky1 2019-08-05
  • 打赏
  • 举报
回复
楼主怎么解决的?可以告知下吗?我这边AES(SHA1PRNG)加密的时候报了这个错误
kousansky 2019-07-25
  • 打赏
  • 举报
回复
我也碰到了该问题,不知道如何解决

110,502

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧