Configure la licencia de IronXL en web.config (C#)

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

El problema ha sido resuelto desde la versión de IronXL 2024.3.20.

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

Para las versiones anteriores de IronXL, específicamente aquellas entre las versiones 2023.4.13 y 2024.3.20, existe un problema conocido de licenciamiento en:

  • Proyectos ASP.NET
  • Versión de .NET Framework >= 4.6.2

La clave almacenada en un archivo Web.config NO será detectada ni utilizada por el producto.

Solución alternativa

Para abordar este problema, se recomienda recuperar la clave de licencia del archivo Web.config utilizando ConfigurationManager en el código, y luego aplicarla a la propiedad License.LicenseKey.

Ejemplo:

A continuación se muestra un ejemplo de cómo almacenar la clave de licencia en un archivo 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>
XML

Con la configuración del archivo XML anterior, podemos usar ConfigurationManager para recuperar el valor de la clave de licencia y establecerlo en la propiedad 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
Dim licenseKey As String = ConfigurationManager.AppSettings("IronXl.LicenseKey")

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

En este ejemplo, se utiliza el ConfigurationManager.AppSettings para recuperar el valor de IronXl.LicenseKey de Web.config. La clave de licencia recuperada se establece a continuación en el IronXl.License.LicenseKey para asegurar que los componentes de IronXL puedan funcionar correctamente.

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 2,052,917 | Versión: 2026.6 just released
Still Scrolling Icon

¿Aún desplazándote?

¿Quieres una prueba rápida? PM > Install-Package IronXL.Excel
ejecuta una muestra observa cómo tus datos se convierten en una hoja de cálculo.