Definindo a chave de licença no arquivo Web.config.
Este problema foi resolvido desde a versão 2024.3.3 do IronPDF.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronPDF must be licensed for development.
Para versões mais antigas do IronPDF , especificamente entre as versões 2023.4.4 e 2024.3.3 , existe um problema conhecido de licenciamento em:
- Projetos ASP.NET
- Versão do .NET Framework >= 4.6.2
A chave armazenada em um arquivo Web.config NÃO será capturada e utilizada pelo produto.
Solução alternativa
Para resolver este problema, recomenda-se recuperar a chave de licença do arquivo Web.config usando ConfigurationManager no código, e então aplicá-la à propriedade License.LicenseKey.
Exemplo:
<configuration>
...
<appSettings>
<add key="IronPdf.LicenseKey" value="IRONPDF-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
<configuration>
...
<appSettings>
<add key="IronPdf.LicenseKey" value="IRONPDF-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
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 IronPDF .
using System.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the Web.config file
string licenseKey = ConfigurationManager.AppSettings["IronPdf.LicenseKey"];
// Apply the license key to the IronPdf library
IronPdf.License.LicenseKey = licenseKey;
// Additional processing can continue here
}
}
using System.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the Web.config file
string licenseKey = ConfigurationManager.AppSettings["IronPdf.LicenseKey"];
// Apply the license key to the IronPdf library
IronPdf.License.LicenseKey = licenseKey;
// Additional processing can continue here
}
}
Imports System.Configuration
Friend Class Program
Shared Sub Main()
' Retrieve the license key from the Web.config file
Dim licenseKey As String = ConfigurationManager.AppSettings("IronPdf.LicenseKey")
' Apply the license key to the IronPdf library
IronPdf.License.LicenseKey = licenseKey
' Additional processing can continue here
End Sub
End Class

