版本不匹配例外
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 (for Windows)
- IronPdf.Native.Chrome.Linux (for Linux)
- IronSoftware.Native.PdfModel
這些依賴項可能不會自動與IronPdf.Slim一起更新,特別是在舊版本中。
解決方案
要解決此問題,請考慮以下選項:
-
重新安裝IronPDF套件:使用Visual Studio中的NuGet套件管理器解除安裝所有與IronPDF相關的套件,然後重新安裝最新版本。 這可以確保移除舊的二進位檔,防止執行時衝突。 請參閱NuGet頁面以獲得相容的依賴項版本。
-
切換到IronPDF:解除安裝IronPdf.Slim及其依賴項,然後安裝完整的IronPDF套件。 這將自動包括所有必要的相容版本的依賴項。
-
啟用自動下載依賴項:解除安裝提到的依賴項,然後使用以下程式碼與IronPdf.Slim一起使用:
// Enables automatic download of native binaries during runtime IronPdf.Installation.AutomaticallyDownloadNativeBinaries = true;// Enables automatic download of native binaries during runtime IronPdf.Installation.AutomaticallyDownloadNativeBinaries = true;' Enables automatic download of native binaries during runtime IronPdf.Installation.AutomaticallyDownloadNativeBinaries = True$vbLabelText $csharpLabel這將在首次運行時下載正確的本機二進位檔和依賴項。 注意這需要網路連接並可能需要一些時間。
如果您需要進一步的幫助,請提交一個工程請求。

