Configuración de la licencia de IronOCR en web.config

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

El problema se ha resuelto a partir de la versión 2024.3.3 de IronZIP .

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

Para versiones más antiguas de IronZIP, específicamente aquellas lanzadas antes de la versión 2024.3.3, existe un problema conocido de licencias en:

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

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

Solución alternativa

Para solucionar este problema, se recomienda recuperar la clave de licencia del archivo Web.config usando ConfigurationManager en el código y luego aplicarlo 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>
XML

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.");
    }
}
$vbLabelText   $csharpLabel
  • La directiva using System.Configuration; permite el acceso a archivos de configuración, como Web.config.
  • ConfigurationManager.AppSettings["IronZip.LicenseKey"] recupera la clave de licencia almacenada en la sección appSettings de Web.config.
  • IronZip.License.LicenseKey = licenseKey; asigna la clave recuperada a la biblioteca IronZIP para evitar excepciones de licencia.
  • La declaración Console.WriteLine() proporciona retroalimentación al desarrollador de que el proceso de solicitud de clave de licencia se completó exitosamente.
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 19,172 | Versión: 2026.3 recién lanzado
Still Scrolling Icon

¿Aún desplazándote?

¿Quieres una prueba rápida? PM > Install-Package IronZip
ejecuta una muestra observa cómo tus archivos se convierten en un archivo.