【问题标题】:Method not found exception when creating a WebClient in NHtmlUnit在 NHtmlUnit 中创建 WebClient 时找不到方法异常
【发布时间】:2015-09-03 18:15:57
【问题描述】:

我使用 NuGet 将 NHtmlUnit Pacakge (v2.15.0.0) 安装到使用 Visual Studio 2015 的 MVC5 项目中。

var client = new WebClient(BrowserVersion.CHROME);

我也尝试过不指定浏览器并使用 IE11。

以下是例外详情:

System.MissingMethodException occurred
  HResult=-2146233069
  Message=Method not found: 'Void java.util.HashMap.__<clinit>()'.
  Source=HtmlUnit
  StackTrace:
       at com.gargoylesoftware.htmlunit.Cache..ctor()
       at com.gargoylesoftware.htmlunit.WebClient..ctor(BrowserVersion browserVersion)
  InnerException: 

以下是调试器对 NHtmlUnit 和 IKVM.OpenJDK.Util.dll .dll 的说明:

Name=NHtmlUnit.dll
Path=C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ef1fc9af\43f83bfb\assembly\dl3\362bd10d\0ab5a1ee_d0e5d001\NHtmlUnit.dll
Optimized=Yes
User Code=N/A
Symbol File=Cannot find or open the PDB file.
Order=109
Version=2.15.0.0
Timestamp=7/11/2014 1:23 AM 
Address=0F6E0000-0F754000
Process=[13336] iisexpress.exe
AppDomain=[2] /LM/W3SVC/2/ROOT-1-130857754150438760 

Name=IKVM.OpenJDK.Util.dll
Path=C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\ef1fc9af\43f83bfb\assembly\dl3\7fc27125\b1c29ef9_d0e5d001\IKVM.OpenJDK.Util.dll
Optimized=Yes
User Code=N/A
Symbol Status:
Binary was not built with debug information.
Order 66
Version=8.01.5717.0
Timestamp=12/31/1969 5:00 PM
Address=0E9D0000-0EAC4000
Process=[13336] iisexpress.exe
AppDomain=[2] /LM/W3SVC/2/ROOT-1-130857754150438760 

这感觉很像 .net 模块版本不匹配,但我有任何参考或曾经使用过任何 NHtmlUnit 或 IKVM dll 的唯一地方是在项目中(它也在干净的机器上重现)。对诊断此问题的方法有何想法?

【问题讨论】:

    标签: c# ikvm nhtmlunit


    【解决方案1】:

    按照以下说明进行操作:

    1. 卸载所有软件包。 (HTMLUnit 和 IKVM)
    2. 清除 App.config 上的运行时设置
    3. 重新安装所有软件包。
    4. 运行您的应用程序。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-10-20
      • 1970-01-01
      • 2017-07-30
      • 2016-06-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多