string licenseKey = config["GemBox:LicenseKey"]; ComponentInfo.SetLicense(licenseKey); # Set on your server/container export GEMBOX_DOCUMENT_LICENSE="A1B2-C3D4-E5F6-G7H8" var key = Environment.GetEnvironmentVariable("GEMBOX_DOCUMENT_LICENSE"); ComponentInfo.SetLicense(key); ✅ Method 4: appSettings in legacy web.config <appSettings> <add key="GemBoxDocumentLicense" value="A1B2-C3D4-E5F6-G7H8"/> </appSettings> string key = ConfigurationManager.AppSettings["GemBoxDocumentLicense"]; ComponentInfo.SetLicense(key); 4. Common Licensing Mistakes & How to Fix Them | Symptom | Likely Cause | Fix | | :--- | :--- | :--- | | “Trial message” on PDF/Image export | No key set, or key is malformed | Call SetLicense before loading any document. Check for extra spaces. | | LicenseException: This license key is not valid for this deployment | Using a Developer license on a live server | Purchase a Site or OEM license. | | Exception in a web app only after some time | Calling SetLicense per request (overhead) or missing static initialization | Set key once in Application_Start or static constructor. | | Everything works locally but fails on Azure/AWS | Key not deployed via environment variable or config file | Use Environment Variables or Azure App Configuration. | 5. Verify Your License Is Active (No More Guessing) Insert this small diagnostic after setting the key:
using GemBox.Document; using Microsoft.Extensions.Configuration; var config = new ConfigurationBuilder() .AddJsonFile("appsettings.json") .Build(); Gembox.document License Key
"GemBox": "LicenseKey": "A1B2-C3D4-E5F6-G7H8" | | LicenseException: This license key is not
Let’s fix that. This guide cuts through the legal jargon and shows you exactly how to obtain, store, and apply your —whether you own a Developer, Site, or OEM license. 1. First, What Kind of License Key Do You Have? GemBox uses a single string (e.g., "ABCD-1234-EFGH-5678" ), but the behavior of that key depends on your purchase. Before coding, identify your license type: identify your license type: