Dépannage de la configuration de la licence IronPrint

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

Le problème a été résolu à partir de la version 2024.3.6 d'IronPrint.

# This shell output shows an unhandled exception error due to missing license for IronPrint.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronPrint must be licensed for development.
# This shell output shows an unhandled exception error due to missing license for IronPrint.
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronPrint must be licensed for development.
SHELL

Pour les anciennes versions d'IronPrint, en particulier celles publiées avant la version 2024.3.6 , il existe un problème de licence connu :

  • projets ASP.NET
  • version .NET Framework >= 4.6.2

La clé stockée dans un fichier Web.config ne sera PAS détectée et utilisée par le produit.

Solution de contournement

Pour résoudre ce problème, il est recommandé de récupérer la clé de licence du fichier Web.config en utilisant ConfigurationManager dans le code, puis de l'appliquer à la propriété License.LicenseKey.

Example:

<configuration>
  ...
  <appSettings>
    <add key="IronPrint.LicenseKey" value="IRONPRINT.MYLICENSE.KEY.1EF01"/>
  </appSettings>
  ...
</configuration>
<configuration>
  ...
  <appSettings>
    <add key="IronPrint.LicenseKey" value="IRONPRINT.MYLICENSE.KEY.1EF01"/>
  </appSettings>
  ...
</configuration>
XML

Avec le fichier XML fourni ci-dessus, nous pouvons utiliser ConfigurationManager pour récupérer la valeur de la clé de licence et la transmettre à la propriété IronPrint.License.LicenseKey .

using System;
using System.Configuration;

namespace IronPrintLicenseSetup
{
    class Program
    {
        static void Main()
        {
            // Retrieve the license key from the appSettings section of the Web.config file.
            string licenseKey = ConfigurationManager.AppSettings["IronPrint.LicenseKey"];

            // Apply the retrieved license key to the IronPrint's LicenseKey property.
            IronPrint.License.LicenseKey = licenseKey;

            // Notify user that the license key has been applied.
            Console.WriteLine("License Key has been applied successfully.");
        }
    }
}
using System;
using System.Configuration;

namespace IronPrintLicenseSetup
{
    class Program
    {
        static void Main()
        {
            // Retrieve the license key from the appSettings section of the Web.config file.
            string licenseKey = ConfigurationManager.AppSettings["IronPrint.LicenseKey"];

            // Apply the retrieved license key to the IronPrint's LicenseKey property.
            IronPrint.License.LicenseKey = licenseKey;

            // Notify user that the license key has been applied.
            Console.WriteLine("License Key has been applied successfully.");
        }
    }
}
Imports System
Imports System.Configuration

Namespace IronPrintLicenseSetup
	Friend Class Program
		Shared Sub Main()
			' Retrieve the license key from the appSettings section of the Web.config file.
			Dim licenseKey As String = ConfigurationManager.AppSettings("IronPrint.LicenseKey")

			' Apply the retrieved license key to the IronPrint's LicenseKey property.
			IronPrint.License.LicenseKey = licenseKey

			' Notify user that the license key has been applied.
			Console.WriteLine("License Key has been applied successfully.")
		End Sub
	End Class
End Namespace
$vbLabelText   $csharpLabel

Dans l'exemple ci-dessus, ConfigurationManager.AppSettings est utilisé pour récupérer la clé de licence directement à partir du fichier Web.config . La clé est ensuite définie comme LicenseKey pour le composant IronPrint, garantissant ainsi que l'application dispose de la licence nécessaire pour fonctionner correctement.

Curtis Chau
Rédacteur technique

Curtis Chau détient un baccalauréat en informatique (Université de Carleton) et se spécialise dans le développement front-end avec expertise en Node.js, TypeScript, JavaScript et React. Passionné par la création d'interfaces utilisateur intuitives et esthétiquement plaisantes, Curtis aime travailler avec des frameworks modernes ...

Lire la suite
Prêt à commencer?
Nuget Téléchargements 34,704 | Version: 2025.11 vient de sortir