0

我已经docx4j.NET 3.0.1从 Nuget 安装了 vs2012。当我尝试通过此调用使用库时

WordprocessingMLPackage.load(inputS, ""); 

我收到此错误:

System.TypeInitializationException: 
The type initializer for 'org.docx4j.openpackaging.packages.OpcPackage' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'slf4j-api,
Version=1.7.6.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies

发行版中的slf4j-api版本docx4j.net 3.0.11.7.5.0.

包的分发有问题吗?

4

1 回答 1

0

检查 VS 项目中引用的 DLL 列表是否包含 slf4j-api。如果没有,请添加它。

如果您正确引用了 DLL,那么按照https://github.com/plutext/docx4j.NET/blob/master/docx4j.NET/src/samples/c%23/Docx4NET/DocxToHTML 中的示例代码。 cs,您可能需要类似的东西(注意底线):

        // Programmatically configure Common Logging
        // (alternatively, you could do it declaratively in app.config)
        NameValueCollection commonLoggingproperties = new NameValueCollection();
        commonLoggingproperties["showDateTime"] = "false";
        commonLoggingproperties["level"] = "INFO";
        LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(commonLoggingproperties);


        ILog log = LogManager.GetCurrentClassLogger();
        log.Info("Hello from Common Logging" );

        // Necessary, if slf4j-api and slf4j-NetCommonLogging are separate DLLs
        ikvm.runtime.Startup.addBootClassPathAssembly(
            System.Reflection.Assembly.GetAssembly(
                typeof(org.slf4j.impl.StaticLoggerBinder)));
于 2014-07-18T21:56:00.143 回答