使用 ReadyToRun 或即時 (AOT) 編譯

This article was translated from English: Does it need improvement?
Translated
View the article in English

.NET ReadyToRun(R2R)是一種提前式(AOT)編譯

在部署過程中啟用 ReadyToRun 編譯可能會違反防篡改保護,並導致出現以下異常。

Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronPdf, Version=2024.2.0.2, Culture=neutral, PublicKeyToken=94e1c31412563c75 assembly is not authentic. Please try to reinstall the nuget package
   at IronPdf.PdfDocument.uswvws(Boolean vhfwdf)
   at IronPdf.PdfDocument.get_BinaryData()
   at IronPdf.PdfDocument.SaveAs(String FileName, Boolean SaveAsRevision)
   at Program.<Main>$(String [] args) in C:\csharppro\aottest\aottest\Program.cs:line 5

原因

根據微軟的文件,SDK 將預編譯隨應用程序分發的組件。 對於自包含應用程序,此組件集將包括框架。 請注意,C++/CLI 二進位檔案不適用於 ReadyToRun 編譯。

解決方案

若要將特定組件排除在 ReadyToRun 處理之外,請使用清單。

<ItemGroup>
    <PublishReadyToRunExclude Include="IronPdf.dll" />
</ItemGroup>
XML