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:
else
Console.WriteLine("License NOT set or invalid."); Gembox.document License Key
ComponentInfo.SetLicense("YOUR-KEY"); // Check status if (ComponentInfo.IsLicenseSet) | | LicenseException: This license key is not
"GemBox": "LicenseKey": "A1B2-C3D4-E5F6-G7H8" string licenseKey = config["GemBox:LicenseKey"]