Configuración de la licencia de IronOCR en web.config
El problema ha sido resuelto a partir de la versión de IronZIP 2024.3.3.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
Para versiones antiguas de IronZIP, específicamente aquellas lanzadas antes de la versión 2024.3.3, existe un problema de licencia conocido en:
- Proyectos ASP.NET
- Versión de .NET Framework >= 4.6.2
La clave almacenada en un archivo Web.config NO será recogida y 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:
<configuration>
...
<appSettings>
<add key="IronZip.LicenseKey" value="IRONZIP.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronZip.LicenseKey" value="IRONZIP.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
Con el archivo XML proporcionado arriba, podemos usar ConfigurationManager para recuperar el valor de la clave de licencia y pasarla a la propiedad IronZip.License.LicenseKey.
using System;
using System.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the web.config appSettings
string licenseKey = ConfigurationManager.AppSettings["IronZip.LicenseKey"];
// Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey;
// Verify that the license key is set properly
Console.WriteLine("License key applied successfully.");
}
}
using System;
using System.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the web.config appSettings
string licenseKey = ConfigurationManager.AppSettings["IronZip.LicenseKey"];
// Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey;
// Verify that the license key is set properly
Console.WriteLine("License key applied successfully.");
}
}
Imports System
Imports System.Configuration
Friend Class Program
Shared Sub Main()
' Retrieve the license key from the web.config appSettings
Dim licenseKey As String = ConfigurationManager.AppSettings("IronZip.LicenseKey")
' Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey
' Verify that the license key is set properly
Console.WriteLine("License key applied successfully.")
End Sub
End Class
- La directiva
using System.Configuration;permite el acceso a archivos de configuración, tales comoWeb.config. ConfigurationManager.AppSettings["IronZip.LicenseKey"]recupera la clave de licencia almacenada en la secciónappSettingsdeWeb.config.IronZip.License.LicenseKey = licenseKey;asigna la clave recuperada a la biblioteca IronZIP para evitar excepciones de licencia.- La instrucción
Console.WriteLine()proporciona al desarrollador retroalimentación de que el proceso de aplicación de la clave de licencia se completó con éxito.

