版本不符例外
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)
- 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這將在首次執行時下載正確的原生二進位檔及依賴項。 請注意,此操作需要網路連線,且可能需要一些時間。
如需進一步協助,請提交工程支援請求。

