Setting License Key in Web.config

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

この問題は IronPDF バージョン 2024.3.3 以降で解決されました

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

For older IronPdf versions, specifically those between versions 2023.4.4 and 2024.3.3, there is a known licensing issue in:

  • ASP.NETプロジェクト
  • .NET Frameworkバージョン >= 4.6.2

Web.configファイルに保存されたキーが製品によって使用されません

回避策

この問題を解決するには、コード内でConfigurationManagerを使用してWeb.configファイルからライセンスキーを取得し、それをLicense.LicenseKeyプロパティに適用することをお勧めします。

例:

<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

上記のXMLファイルを使用して、ConfigurationManager を使ってライセンスキーの値を取得し、IronPdf.License.LicenseKey プロパティに渡すことができます。

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
テクニカルライター

Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。

開発以外にも、CurtisはIoT(Internet of Things)への強い関心を持ち、ハードウェアとソフトウェアの統合方法を模索しています。余暇には、ゲームをしたりDiscordボットを作成したりして、技術に対する愛情と創造性を組み合わせています。

準備はいいですか?
Nuget ダウンロード 16,154,058 | バージョン: 2025.11 ただ今リリースされました