Configure a Licença IronXL no web.config (C#)
O problema foi resolvido a partir da versão 2024.3.20 do IronXL.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
Para versões mais antigas do IronXL, especificamente entre as versões 2023.4.13 e 2024.3.20 , existe um problema conhecido de licenciamento em:
- Projetos ASP.NET
- Versão do .NET Framework >= 4.6.2
A chave armazenada em um arquivo Web.config NÃO será captada e usada pelo produto.
Solução alternativa
Para resolver este problema, é recomendado recuperar a chave de licença do arquivo Web.config usando ConfigurationManager no código, e depois aplicá-la à propriedade License.LicenseKey.
Exemplo:
Abaixo está um exemplo de como armazenar a chave de licença em um arquivo Web.config:
<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>
Com a configuração do arquivo XML acima, podemos usar ConfigurationManager para recuperar o valor da chave de licença e defini-lo para a propriedade IronXL.License.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;
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
Neste exemplo, ConfigurationManager.AppSettings é usado para recuperar o valor de IronXL.LicenseKey de Web.config. A chave de licença recuperada é então configurada para IronXL.License.LicenseKey para garantir que os componentes do IronXL possam funcionar corretamente.

