不能在Visual Studio C#项目中使用libpdf.dll

时间:2013-09-20 07:09:12

标签: c# visual-studio-2010 dll

我从http://code.google.com/p/lib-pdf/downloads/list

下载了libpdf.dll及其依赖项

然后我将dll复制到项目“bin”文件夹中的“debug”文件夹中。然后,我添加了对libpdf.dll的引用

当我运行示例代码时:

using (FileStream file = File.OpenRead(@"D:\test\pdfs\sample.pdf")) // in file
            {
                var bytes = new byte[file.Length];
                file.Read(bytes, 0, bytes.Length);
                using (var pdf = new LibPdf(bytes))
                {
                    byte[] pngBytes = pdf.GetImage(0, ImageType.PNG); // image type
                    using (var outFile = File.Create(@"D:\test\pdfs\file.png")) // out file
                    {
                        outFile.Write(pngBytes, 0, pngBytes.Length);
                    }
                }
            }

我收到以下错误:

  

无法加载由'libpdf.dll'导入的过程。       确保该文件是有效的.Net Framework程序集。

如何继续解决此错误?我怎么知道它在说什么dll?

1 个答案:

答案 0 :(得分:1)

startup Element MSDN

在配置文件中包含以下内容

<startup useLegacyV2RuntimeActivationPolicy="true">
</startup>