Web.config Dosyasında Lisans Anahtarını Ayarlama

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

Bu sorun IronPDF 2024.3.3 sürümünden itibaren çözüldü.

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

Özellikle 2023.4.4 ve 2024.3.3 sürümleri arasındaki eski IronPdf sürümleri için, aşağıdaki durumlarda bilinen bir lisanslama sorunu bulunmaktadır:

  • ASP.NET projeleri
  • .NET Framework sürümü >= 4.6.2

Anahtar, Web.config dosyasına kaydedildiğinde, ürün tarafından KULLANILMAYACAK ve alınmayacaktır.

Geçici Çözüm

Bu sorunu çözmek için, lisans anahtarını kod içinde ConfigurationManager kullanarak Web.config dosyasından alıp, ardından License.LicenseKey özelliğine uygulamanız önerilir.

Örnek:

<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>
XML

Yukarıda sağlanan XML dosyası ile, lisans anahtar değerini almak ve IronPdf.License.LicenseKey özelliğine iletmek için ConfigurationManager kullanabiliriz.

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
$vbLabelText   $csharpLabel
Curtis Chau
Teknik Yazar

Curtis Chau, Bilgisayar Bilimleri alanında lisans derecesine sahiptir (Carleton Üniversitesi) ve Node.js, TypeScript, JavaScript ve React konularında uzmanlaşmış ön uç geliştirme üzerine uzmanlaşmıştır. Kullanıcı dostu ve estetik açıdan hoş arayüzler tasarlamaya tutkuyla bağlı olan Curtis, modern çerç...

Daha Fazlasını Oku
Başlamaya Hazır mısınız?
Nuget Indirmeler 18,332,619 | Sürüm: 2026.4 yeni yayınlandı
Still Scrolling Icon

Hala Kaydiriyor musunuz?

Hızlı bir kanit mi istiyorsunuz? PM > Install-Package IronPdf
bir örnek çalıştır HTML'nizin PDF olduğunu izleyin.