Csharp/C#教程:在unit testing中获取错误“Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl”但在主程序中没有分享


在unit testing中获取错误“Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl”但在主程序中没有

我在C#中构建一个应用程序,它使用com.gargoylesoftware.htmlunit.WebClient来访问和检索来自网页的信息。

我的应用程序从主项目运行良好,但当我尝试构建unit testing来测试项目类时,我收到以下错误:

FactoryConfigurationError Message "Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found" Source "IKVM.OpenJDK.XML.API" string StackTrace " at javax.xml.parsers.DocumentBuilderFactory.newInstance() at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.loadConfiguration(Reader configurationReader) at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.loadConfiguration() at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration..ctor(BrowserVersion ) at com.gargoylesoftware.htmlunit.javascript.configuration.JavaScriptConfiguration.getInstance(BrowserVersion browserVersion) at com.gargoylesoftware.htmlunit.javascript.JavaScriptEngine..ctor(WebClient webClient) at com.gargoylesoftware.htmlunit.WebClient.init(BrowserVersion , ProxyConfig ) at com.gargoylesoftware.htmlunit.WebClient..ctor(BrowserVersion browserVersion) at com.gargoylesoftware.htmlunit.WebClient..ctor() at GWT.HeadlessBrowser..ctor() in C:\hg\EXE\GWT\HeadlessBrowser.cs:line 57 at TestGWT.ProgramTest.TestLogInProcessForGWT() in C:\hg\TestGWT\ProgramTest.cs:line 115" 

尝试在unit testing类中创建HtmlUnit WebClient也会导致此错误。

我在主项目和包含unit testing的项目中都有项目引用htmlunit-2.7,IKVM.OpenJDK.Core和IKVM.OpenJDK.XML.API。

我是否需要额外的项目参考才能运行unit testing? 可能导致此错误的原因是什么?

测试类使用Microsoft.VisualStudio.TestTools.UnitTesting;

最近我在测试同一个库时遇到了同样的问题。 我发现包含对IKVM.OpenJDK.XML.Parse.dll的引用解决了这个问题。

我遇到了类似的问题。

似乎没有加载com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl类,因此工厂无法创建它。 在调用工厂之前添加这一行会强制加载程序集,然后工厂可以看到它,一切都按预期工作……

上述就是C#学习教程:在unit testing中获取错误“Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl”但在主程序中没有分享的全部内容,如果对大家有所用处且需要了解更多关于C#学习教程,希望大家多多关注—计算机技术网(www.ctvol.com)!

 com.sun.org.apache.xerces.@internal.jaxp.SAXParserFactoryImpl s = new com.sun.org.apache.xerces.@internal.jaxp.SAXParserFactoryImpl(); 

本文来自网络收集,不代表计算机技术网立场,如涉及侵权请联系管理员删除。

ctvol管理联系方式QQ:251552304

本文章地址:https://www.ctvol.com/cdevelopment/1000156.html

(0)
上一篇 2021年12月27日
下一篇 2021年12月27日

精彩推荐