【问题标题】:C#:Java error in .NET 2.0 frameworkC#:.NET 2.0 框架中的 Java 错误
【发布时间】:2013-07-04 17:23:24
【问题描述】:

我的应用程序出现以下错误,

错误:

System.TypeInitializationException: The type initializer for 'java.util.Locale' threw an exception. ---> java.lang.UnsatisfiedLinkError: Unable to load DLL 'vjsnativ': The specified module could not be found. (Exception from HRESULT: 0x8007007E) ---> System.DllNotFoundException: Unable to load DLL 'vjsnativ': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at com.ms.vjsharp.windowing.win32.UnsafeWin32Calls.GetLocaleInfo<PInvokeHelper>vjsnativ(Int32 lcid, Int32 lctype, StringBuilder lpLCData, Int32 cchData)
   at com.ms.vjsharp.windowing.win32.UnsafeWin32Calls.GetLocaleInfo(Int32 lcid, Int32 lctype, StringBuffer lpLCData, Int32 cchData)
   at java.util.Locale..ctor(CultureInfo ci, String language, String ctryRgn, String variant)
   at java.util.Locale..ctor(String languageCode, String ctryRgnCode)
   at java.util.Locale..cctor()
   --- End of inner exception stack trace ---
   at java.lang.ExceptionInInitializerError.checkAndThrowException(Throwable thrown)
   at java.util.Locale..cctor()
   --- End of inner exception stack trace ---
   at java.util.Locale.getDefault()
   at com.ms.vjsharp.lang.StringImpl.toUpperCase(String mrString)
   at com.vividsolutions.jts.io.WKTReader.getNextWord(StreamTokenizer tokenizer)
   at com.vividsolutions.jts.io.WKTReader.readGeometryTaggedText(StreamTokenizer tokenizer)
   at com.vividsolutions.jts.io.WKTReader.read(Reader reader)
   at com.vividsolutions.jts.io.WKTReader.read(String wellKnownText)

我正在使用 .net 2.0,windows xp 操作系统。请检查并告诉我您的答案和建议。

谢谢

【问题讨论】:

  • 你真的需要使用J#吗?很久以前就停产了。
  • 为什么要投反对票?有些人被困在与遗留的第三方库集成 - 这篇文章对我有很大帮助

标签: c#-2.0


【解决方案1】:

您可以找到 vjsnativ.dll 并将其复制到您的应用程序目录,或者您可以在调用任何 J# 代码之前添加此代码。

// This problem started with .NET 4
if (Environment.Version.Major >= 4)
{
    string dllpath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.System), @"..\Microsoft.NET\Framework\v2.0.50727");
    dllpath = Path.GetFullPath(dllpath);
    LoadLibrary(Path.Combine(dllpath, "vjsnativ.dll"));
}
// J# code should work now

【讨论】:

  • 除了未定义 LoadLibrary 之外,Assembly.LoadFile 为此文件提供以下错误:该模块应包含程序集清单。 (HRESULT 异常:0x80131018)
  • 所以让LoadLibrary定义:[DllImport("kernel32.dll")] public static extern IntPtr LoadLibrary(string dllToLoad);
猜你喜欢
  • 2019-10-08
  • 1970-01-01
  • 2015-04-19
  • 2015-12-21
  • 1970-01-01
  • 2010-12-26
  • 2013-08-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多