Como Configurar Licença IronXL em web.config para Planilha Excel em 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á detectada e usada pelo produto.
Solução alternativa
Para resolver esse problema, recomenda-se recuperar a chave de licença do arquivo Web.config usando o ConfigurationManager no código e, em seguida, aplicá-la à propriedade License.LicenseKey.
Exemplo:
Abaixo segue 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 o arquivo XML configurado acima, podemos usar o ConfigurationManager para recuperar o valor da chave de licença e defini-lo na 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, o ConfigurationManager.AppSettings é usado para recuperar o valor de IronXL.LicenseKey de Web.config. A chave de licença recuperada é então definida como IronXL.License.LicenseKey para garantir que os componentes do IronXL possam funcionar corretamente.

