Use ReadyToRun or ahead-of-time (AOT) Compilation

.NET ReadyToRun (R2R) is a form of ahead-of-time (AOT) compilation.

Enabling ReadyToRun compilation during deployment might violate tampering protection and result in the following exception.

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

Reason

According to Microsoft documentation, the SDK will precompile the assemblies that are distributed with the application. For self-contained applications, this set of assemblies will include the framework. It's important to note that C++/CLI binaries are not eligible for ReadyToRun compilation.

Solution

To exclude specific assemblies from ReadyToRun processing, use thelist.

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