C# 获取错误“;提供者com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl未找到;单元测试中,但不在主程序中
我正在用C#构建一个应用程序,它使用com.gargoylesoftware.htmlunit.WebClient从网页访问和检索信息 我的应用程序在主项目中运行良好,但当我尝试构建单元测试来测试项目类时,我遇到以下错误:C# 获取错误“;提供者com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl未找到;单元测试中,但不在主程序中,c#,unit-testing,webclient,htmlunit,C#,Unit Testing,Webclient,Htmlunit,我正在用C#构建一个应用程序,它使用com.gargoylesoftware.htmlunit.WebClient从网页访问和检索信息 我的应用程序在主项目中运行良好,但当我尝试构建单元测试来测试项目类时,我遇到以下错误: FactoryConfigurationError Message "Provider com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl not found" Source "IKVM.Op
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"
尝试在单元测试类中创建HtmlUnit WebClient也会导致此错误
我在主项目和包含单元测试的项目中都有项目参考htmlunit-2.7、IKVM.OpenJDK.Core和IKVM.OpenJDK.XML.API
运行单元测试是否需要额外的项目参考?是什么导致了这个错误
测试类使用Microsoft.VisualStudio.TestTools.UnitTesting 我最近在测试同一个库时遇到了同样的问题。我发现包含对IKVM.OpenJDK.XML.Parse.dll的引用解决了这个问题。我遇到了类似的问题 似乎com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl类未加载,因此工厂无法创建它。在调用工厂之前添加这一行将强制加载程序集,然后工厂可以看到它,一切都按预期工作
com.sun.org.apache.xerces.@internal.jaxp.SAXParserFactoryImpl s = new com.sun.org.apache.xerces.@internal.jaxp.SAXParserFactoryImpl();
凯蒂:答案解决了你的问题吗?添加此代码效果很好。VB.Net Dim s作为com.sun.org.apache.xerces.internal.jaxp.saxparserfactorympl=New com.sun.org.apache.xerces.internal.jaxp.saxparserfactorympl()