PDFSharp 程序集清单定义

PDFSharp Assembly manifest definition

我从 Nuget 管理器安装了 PDFSharp/MigraDoc 并尝试使用它。当我尝试编写 PDF 时出现此错误:

Could not load file or assembly 'PdfSharp, Version=1.32.3057.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

它给了我一个程序集加载轨迹,如下:

=== Pre-bind state information ===
LOG: DisplayName = PdfSharp, Version=1.32.3057.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb
 (Fully-specified)
LOG: Appbase = file:///C:/Users/jh/Documents/GitHub/Base1.5/Website/
LOG: Initial PrivatePath = C:\Users\jh\Documents\GitHub\Base1.5\Website\bin
Calling assembly : MigraDoc.Rendering, Version=1.32.4334.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Users\jhop\Documents\GitHub\Base1.5\Website\web.config
LOG: Using host configuration file: C:\Users\jhop\Documents\IISExpress\config\aspnet.config
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
LOG: Post-policy reference: PdfSharp, Version=1.32.3057.0, Culture=neutral, PublicKeyToken=f94615aa0424f9eb
LOG: Attempting download of new URL file:///C:/Users/jh/AppData/Local/Temp/Temporary ASP.NET Files/vs/81f4fd95/d5ff50bc/PdfSharp.DLL.
LOG: Attempting download of new URL file:///C:/Users/jh/AppData/Local/Temp/Temporary ASP.NET Files/vs/81f4fd95/d5ff50bc/PdfSharp/PdfSharp.DLL.
LOG: Attempting download of new URL file:///C:/Users/jh/Documents/GitHub/Base1.5/Website/bin/PdfSharp.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

我该怎么做才能解决这个问题?

请注意,MigraDoc 包中包含 PDFsharp,因此不要将 PDFsharp 和 MigraDoc 作为与 NuGet 分开的包安装。

不同的版本号 1.32.4334 和 1.32.3057 表明您安装了不同且不兼容的 NuGet 包,或者可能引用了根本不是来自 NuGet 的程序集。