IRONSOFTWAREHOME

Use ReadyToRun or Ahead-Of-Time (AOT) Compilation

Curtis Chau
Curtis Chau
Updated: June 11, 2026

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

Enabling ReadyToRun compilation during deployment might violate tampering protection and result in exceptions such as the following:

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
Text

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 the <PublishReadyToRunExclude> list in your project file. For example, to exclude the IronPdf.dll assembly:

<ItemGroup>
    <!-- Excludes IronPdf.dll from ReadyToRun compilation -->
    <PublishReadyToRunExclude Include="IronPdf.dll" />
</ItemGroup>
XML

This XML snippet should be added to your project file (.csproj) to prevent the specified assemblies from being precompiled with ReadyToRun, thus avoiding potential licensing or tampering issues.

System.Environment.FailFast on First IronPDF Call

In some Windows deployments, IronPDF crashes the process immediately on the first IronPDF call with no application-level log output. Windows Event Log records an entry similar to:

The application requested process termination through System.Environment.FailFast.
Message: Stack: at System.Environment.FailFast(System.String)
  at <Module>..cctor()
  at Program.<Main>$(System.String[])
Text

This is a different failure from the licensing exception above. The crash occurs during static initialization before normal logging is available, so no IronPDF log lines appear before the process terminates.

This pattern has been confirmed in ASP.NET Core applications hosted in IIS on Windows Server with PublishReadyToRun enabled. It has been reproduced on:

  • IronPDF 2026.4.1
  • .NET 10
  • IIS (w3wp.exe) on Windows Server 2025 Datacenter
  • AWS EC2 win-x64 publish target

Solution

Keep <PublishReadyToRun>true</PublishReadyToRun> for the application and exclude only IronPdf.dll:

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

A full .csproj example:

<PropertyGroup>
    <TargetFramework>net10.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>

<ItemGroup>
    <PackageReference Include="IronPdf" Version="2026.4.1" />
</ItemGroup>

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

After updating the .csproj, republish the application, redeploy, and restart the IIS site or recycle the Application Pool.

Curtis Chau
Technical Writer

Curtis Chau holds a Bachelor’s degree in Computer Science (Carleton University) and specializes in front-end development with expertise in Node.js, TypeScript, JavaScript, and React. Passionate about crafting intuitive and aesthetically pleasing user interfaces, Curtis enjoys working with modern frameworks and creating well-structured, visually appealing manuals.

...
Read More

Ready to Get Started?

Nuget Downloads 21,105,021Version:2026.9just released

Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999

Key in blue circle

Get your free 30-day Trial Key instantly.

Your trial license will be sent to your email address

No limitations. 100% unlocked. No credit card.

OR
bullet_checkedNo credit card or account creation requiredNo limitations. 100% unlocked. No credit card.
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried Iron Suite
Book your free Live Demo
Booking Badge

Trusted by Millions of Engineers Worldwide

Iron Software's customer logos
Get Your No-Obligation Consult
Complete the form below or email sales@ironsoftware.com
Your details will always be kept confidential.
Trusted by Millions of Engineers Worldwide
Iron Software's customer logos
Get your free 30-day Trial Key instantly.
No credit card or account creation required
C# NuGet Library for PDF
Install with NuGet

Version: 2026.9

PM > Install-Package IronPdf
nuget.org/packages/IronPdf/
  1. In Solution Explorer, right-click References, Manage NuGet Packages
  2. Select Browse and search "IronPdf"
  3. Select the package and install
C# PDF DLL
Download DLL

Version: 2026.9

or download Windows Installer here.

  1. Download and unzip IronPDF to a location such as ~/Libs within your Solution directory
  2. In Visual Studio Solution Explorer, right click References. Select Browse, "IronPdf.dll"

Licenses from $999