簡體   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