Configuração da licença do IronOCR no arquivo web.config.

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

O problema foi resolvido a partir da versão 2024.3.3 do 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 versões antigas do IronZIP, especificamente aquelas lançadas antes da versão 2024.3.3, há um problema de licenciamento conhecido 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:

<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

Com o arquivo XML fornecido acima, podemos usar o ConfigurationManager para recuperar o valor da chave de licença e passá-lo para a propriedade IronZIP .

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
  • A diretiva using System.Configuration; permite o acesso a arquivos de configuração, como Web.config.
  • ConfigurationManager.AppSettings["IronZip.LicenseKey"] recupera a chave de licença armazenada na seção appSettings de Web.config.
  • IronZip.License.LicenseKey = licenseKey; atribui a chave recuperada à biblioteca IronZIP para evitar exceções de licenciamento.
  • A declaração Console.WriteLine() fornece feedback ao desenvolvedor de que o processo de solicitação da chave de licença foi concluído com sucesso.
Curtis Chau
Redator Técnico

Curtis Chau é bacharel em Ciência da Computação (Universidade Carleton) e se especializa em desenvolvimento front-end, com experiência em Node.js, TypeScript, JavaScript e React. Apaixonado por criar interfaces de usuário intuitivas e esteticamente agradáveis, Curtis gosta de trabalhar com frameworks modernos e criar manuais ...

Leia mais
Pronto para começar?
Nuget Baixar 21,060 | Versão: 2026.6 just released
Still Scrolling Icon

Ainda está rolando a tela?

Quer provas rápidas? PM > Install-Package IronZip
executar um exemplo Veja seus arquivos se transformarem em um arquivo morto.