bool isValid = License.IsValidLicense("YOUR-KEY");
if (!isValid)
throw new Exception("License key invalid or expired");
Use this in your startup health check.
Program.cs
using IronPdf; using Microsoft.Extensions.Configuration;var builder = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .AddEnvironmentVariables();
var config = builder.Build();
// Set license key from config or env var IronPdf.License.LicenseKey = config["IronPdf:LicenseKey"];
// Verify if (!IronPdf.License.IsValidLicense) throw new Exception("Invalid IronPDF license key");
// Your PDF generation code here...
appsettings.json
"IronPdf":
"LicenseKey": "IRONPDF-YOUR-KEY-HERE"
IronPDF binds evaluation keys to a specific machine fingerprint. If you change hardware (RAM, CPU, Disk) or clone a VM, the key breaks. Solution: Log into the Iron Software portal and "deactivate" the old machine to release the license lock, or purchase a key that supports floating licenses. ironpdf license key
You can store the key in configuration to avoid hardcoding.
<configuration>
<appSettings>
<add key="IronPdf.LicenseKey" value="IRONPDF-YOUR-ACTUAL-KEY" />
</appSettings>
</configuration>
Then in code, you can load it:
string key = ConfigurationManager.AppSettings["IronPdf.LicenseKey"];
IronPdf.License.LicenseKey = key;
A: Immediately log into the Iron Software portal and "Regenerate" your license key. This invalidates the old key instantly. Deploy the new key to your servers. bool isValid = License