IronPDF - ReadyToRun Deployment System.Environment.FailFast
If your .NET application crashes with System.Environment.FailFast when it first touches IronPDF, the issue may be related to ReadyToRun (R2R) compilation. In affected deployments, the fix is to keep ReadyToRun enabled for the application, but exclude IronPdf.dll from ReadyToRun compilation.
Environment
This article is most relevant for deployments like these:
- IronPDF
- .NET applications published with ReadyToRun enabled
- ASP.NET Core or IIS-hosted applications
- Windows environments, including Windows Server
win-x64publish targets
A confirmed real-world case was resolved in this environment:
- IronPDF 2026.4.1
- .NET 10
- ASP.NET Core web app
- IIS (
w3wp.exe) - Windows Server 2025 Datacenter
- AWS EC2
Symptoms
You may be affected by this issue if:
- the application works normally until it first touches an IronPDF class
- the process terminates immediately at startup or during early initialization
- Windows Event Log shows an error similar to this:
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[])
You may also notice:
- no IronPDF logs are written before the crash
- the issue appears only in the deployed environment
- the same machine may work differently outside IIS than inside IIS
Why This Happens
ReadyToRun compiles assemblies ahead of time to improve startup performance. In some environments, this can interfere with libraries that rely on runtime initialization behavior, including IronPDF.
As a result, the application may fail very early, sometimes before normal logging is available.
Solution
1. Keep ReadyToRun enabled
If your application depends on ReadyToRun, you do not need to disable it entirely.
Make sure your project still includes:
<PropertyGroup>
<PublishReadyToRun>true</PublishReadyToRun>
</PropertyGroup>
2. Exclude IronPdf.dll from ReadyToRun compilation
Add this to your .csproj file:
<ItemGroup>
<PublishReadyToRunExclude Include="IronPdf.dll" />
</ItemGroup>
3. Example .csproj
A working example looks like this:
<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>
4. Republish and redeploy
After updating the project file:
- Rebuild the application.
- Republish it for your intended runtime, such as
win-x64. - Redeploy the updated build.
- Restart the IIS site or recycle the Application Pool.
- Test the same IronPDF code path again.
Important Notes
- Use the exact syntax shown above.
- Do not wrap the exclusion inside another
<PublishReadyToRunExclude>container block. - The key working line is:
<PublishReadyToRunExclude Include="IronPdf.dll" />
Result
In the confirmed production case behind this article, excluding IronPdf.dll from ReadyToRun compilation resolved the System.Environment.FailFast crash and restored normal application behavior under IIS.
When to Try This Fix
This fix is especially relevant if:
PublishReadyToRun=trueis enabled- the crash happens on the first IronPDF call
- the error appears during startup or early static initialization
- the application is hosted in IIS or another deployed Windows environment
🔗 Further Reading
For full guidance on using IronPDF with ReadyToRun, visit our official documentation:
👉 Troubleshooting ReadyToRun with IronPDF