我遇到了一个奇怪的问题。我编写了一个dll (作为Navision的加载项),它调用控制台应用程序throu process.start()。控制台应用程序使用IKVM来使用pdfbox.net (v1.8.4)。
如果我直接运行控制台应用程序(在visual studio中使用cmd或"start“),一切都可以正常工作。如果我从类libary (用单元测试(Mstest)测试)或任何其他( test -)项目启动控制台应用程序from process.start(),就会得到一个异常:
提供程序com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl :找不到javax.xml.parsers.FactoryConfigurationError
类库中的process.start:
string[] args = {pdfFilePath, zugferdFilePath};
ProcessStartInfo processStartInfo = new ProcessStartInfo
{
FileName = exeFile,
Arguments = string.Join(" ", args),
WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location),
ErrorDialog = true,
RedirectStandardError = true,
RedirectStandardOutput = true,
UseShellExecute = false
};
Process process = Process.Start(processStartInfo);有关异常的详细信息:消息:
找不到提供者com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl
来源:
IKVM.OpenJDK.XML.API
StackTrace:
((java.lang.Throwable)_exception) C:\GIT\KCorp.NAV.Zugferd\KCorp.Nav.Zugferd.Split\Mustang\ZUGFeRDImport.cs:Zeile 124中的贝贝贝贝Mustang.ZUGFeRDImporter.parse() .StackTrace,C:\GIT\KCorp.NAV.Zugferd\KCorp.Nav.Zugferd.Split\Zaumzeug.cs:Zeile 30中的bei KCorp.Nav.Zugferd.Split.Zaumzeug.showZUGFeRD(String filepath,String xmlFilePath)。
有人知道怎么解决这个问题吗?
如果您需要进一步的信息,请告诉我。
提前谢谢。
发布于 2016-05-02 09:20:18
这是类装入器的问题。尝试在调用工厂的行之前添加以下内容:
var s = new com.sun.org.apache.xerces.@internal.jaxp.SAXParserFactoryImpl();这将迫使程序集加载,并在每次遇到此问题时都为我工作。
https://stackoverflow.com/questions/36978821
复制相似问题