Configure IronXL License in web.config (C#)

This article was translated from English: Does it need improvement?
Translated
View the article in English

The problem has been resolved as of IronXL version 2024.3.20.

Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.

For older IronXL versions, specifically those between versions 2023.4.13 and 2024.3.20, there is a known licensing issue in:

  • ASP.NET projects
  • .NET Framework version >= 4.6.2

The key stored in a Web.config file will NOT be picked up and used by the product.

Workaround

To address this issue, it is recommended to retrieve the license key from the Web.config file using ConfigurationManager in the code, and then apply it to the License.LicenseKey property.

Example:

Below is an example of how to store the license key in a Web.config file:

<configuration>
  ...
  <appSettings>
    <add key="IronXL.LicenseKey" value="IronXL-MYLICENSE-KEY-1EF01"/>
  </appSettings>
  ...
</configuration>
<configuration>
  ...
  <appSettings>
    <add key="IronXL.LicenseKey" value="IronXL-MYLICENSE-KEY-1EF01"/>
  </appSettings>
  ...
</configuration>
XML

With the above XML file setup, we can use ConfigurationManager to retrieve the license key value and set it to the IronXL.License.LicenseKey property:

using System.Configuration;

// Retrieve the license key from the Web.config appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXL.LicenseKey"];

// Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey;
using System.Configuration;

// Retrieve the license key from the Web.config appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXL.LicenseKey"];

// Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey;
Imports System.Configuration

' Retrieve the license key from the Web.config appSettings section
Private licenseKey As String = ConfigurationManager.AppSettings("IronXL.LicenseKey")

' Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey
$vbLabelText   $csharpLabel

In this example, the ConfigurationManager.AppSettings is used to retrieve the value of IronXL.LicenseKey from Web.config. The retrieved license key is then set to the IronXL.License.LicenseKey to ensure that the IronXL components can function properly.

Curtis Chau
Escritor Técnico

Curtis Chau tiene una licenciatura en Ciencias de la Computación (Carleton University) y se especializa en el desarrollo front-end con experiencia en Node.js, TypeScript, JavaScript y React. Apasionado por crear interfaces de usuario intuitivas y estéticamente agradables, disfruta trabajando con frameworks modernos y creando manuales bien ...

Leer más
¿Listo para empezar?
Nuget Descargas 1,686,155 | Versión: 2025.11 recién lanzado