Licenseinfo.setlicensekey
public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>(); );
For a Windows Forms or WPF application, place it inside the Main method before any licensed control is instantiated:
// Set license key as early as possible LicenseInfo.SetLicenseKey("YOUR_LICENSE_KEY_HERE");
| Vendor | Namespace | Additional Requirements | |--------|-----------|--------------------------| | Telerik | Telerik.Licensing | Must call before any Telerik control is instantiated. | | DevExpress | DevExpress.Data | Also requires adding a license file for design-time. | | Syncfusion | Syncfusion.Licensing | Use SyncfusionLicenseProvider.RegisterLicense() instead. | | GrapeCity (ComponentOne) | C1.Licensing | Use C1License.SetLicenseKey() . | licenseinfo.setlicensekey
Renew your subscription and obtain a new license key. 3. Method Has No Effect Cause: Some vendors require also installing a .licx file or registry entry; setlicensekey only supplements, not replaces, design-time licensing.
// Custom internal implementation LicenseInfo.SetLicenseKey(string productName, string licenseKey);
CreateHostBuilder(args).Build().Run();
// Telerik UI for WinForms / ASP.NET LicenseInfo.SetLicenseKey(string licenseKey); // DevExpress LicenseInfo.SetLicenseKey(string licenseKey);
[STAThread] static void Main()
else
LicenseInfo.SetLicenseKey("YOUR_LICENSE_KEY_HERE"); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MainForm());
Always check the latest vendor documentation, as licensing APIs change over time. licenseinfo.setlicensekey is a straightforward but critical API for programmatically activating licensed UI components or frameworks at runtime. When used correctly – early in the application lifecycle and with secure key management – it enables smooth deployment to CI, containers, and production servers without manual license installation.
Ensure the method is called before the first licensed control is created. Verify the key string (no extra spaces, correct encoding). 2. LicenseExpiredException Cause: The license key has passed its expiration date (common for annual subscriptions). | | GrapeCity (ComponentOne) | C1