繁体   English   中英

PdfiumViewer Pdfium Exception - VS2017 Created Project must be .Net 4.0 然后升级到任何更高版本

[英]PdfiumViewer Pdfium Exception - VS2017 Created Project must be .Net 4.0 and then upgrade to any higher versions

VS2017 版本 15.9.3

NuGet 包 PdfiumViewer 版本="2.13.0.0"

PdfiumViewer.Native.x86_64.v8-xfa version="2018.4.8.256"

测试场景 - 使用 PdfiumViewer 加载 PDF 文件

  1. 创建 Project1:Target Framework = .Net Framework 4。程序运行成功。
  2. 将 Project1 更改为任何更高的 Framework - 4.5, 4.5, 4.6 ... 4.72 程序运行成功

3. 创建 Project2:目标框架 = .Net Framework 4.7.2 或任何其他 FW 4.5、4.5、4.6(** 不是 FW 4)。
错误消息:$exception {“尝试加载格式不正确的程序。(来自 HRESULT 的异常:0x8007000B)”} System.BadImageFormatException

  1. 将 Project2 更改为 FW = 4。程序运行成功。
  2. 将 Project2 更改为任何更高的 Framework - 4.5, 4.5, 4.6 ... 4.72 程序运行成功

代码

错误消息:$exception {“尝试加载格式不正确的程序。(来自 HRESULT 的异常:0x8007000B)”} System.BadImageFormatException

  private void button1_Click(object sender, EventArgs e)
  {
     string pdf = @"D:\PDF\TestFile.pdf";

     try
     {
        var document = PdfiumViewer.PdfDocument.Load(pdf);   // *** Exception  ***
        MessageBox.Show("OK");
     }
     catch (Exception ex)
     {
        MessageBox.Show(ex.Message);
     }
  }

==============

帮助表示赞赏。

将包含pdfium.dllx86x64文件夹添加到 Debug/Release 目录,应该是这样。 如果您不知道在哪里可以找到它们,请从PdfiumViewer Github运行PdfiumViewer.Demo项目,您将在bin文件夹中找到它们。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM