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 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.
SHELL

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>
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.");
    }
}
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
$vbLabelText   $csharpLabel
  • La directiva using System.Configuration; permite el acceso a archivos de configuración, tales 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 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.
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 21,060 | Versión: 2026.6 just released
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.