版本不匹配异常
2022年5月19日
已更新 2024年10月20日
This article was translated from English: Does it need improvement?
TranslatedView the article in English
Invalid assembly version for 'IronInterop' (actual: 2022.x.x.xxxx; expected: 2022.x.x.xxxx). This version of IronPdf requires updated native dependencies. Please clear your build output directory of old assemblies so IronPdf can automatically download the new dependencies at runtime. Alternatively, you may add NuGet package IronPdf.Native.Chrome version 2022.x.xxxx to your project and rebuild.
當 IronPdf.Slim 套件及其相依性因版本不匹配而不兼容時,會發生此錯誤。
可能原因
此錯誤通常發生在僅更新了IronPdf.Slim套件,而其依賴項仍然過時的情況下。
IronPdf.Slim 套件的主要依賴項包括:
- IronSoftware.Common
- IronSoftware.System.Drawing
IronPdf.Native.Chrome
- IronPdf.Native.Chrome.Windows(適用於 Windows)
- IronPdf.Native.Chrome.Linux(適用於 Linux)
這些依賴項可能不會與 IronPdf.Slim 自動更新,特別是在較舊的版本中。
解決方案
要解決這個問題,請考慮以下選項:
- 重新安裝 IronPDF 套件:在 Visual Studio 中使用 NuGet 套件管理器卸載所有與 IronPDF 相關的套件,然後重新安裝最新版本。 這確保了舊的二進制文件被移除,防止運行時衝突。 請參閱NuGet 頁面以獲取相容的依賴項版本。
- 切換至 IronPdf:卸載 IronPdf.Slim 及其相依性,然後安裝完整的 IronPdf 套件包。 這會自動包含所有必要的相容版本依賴項。
啟用自動下載依賴項:卸載所提及的依賴項並通過以下代碼使用IronPdf.Slim:
IronPdf.InstallationAutomaticallyDownloadNativeBinaries = true;
。 這將在初始運行期間下載正確的本地二進制文件和依賴項。 請注意,這需要網路連接,可能需要一些時間。如需進一步協助,請提交工程請求。