Web.configでライセンスキーを設定する
この問題は、 IronPDFバージョン2024.3.3以降で解決されています。
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronPDF must be licensed for development.
古いIronPDFバージョン、特にバージョン2023.4.4から2024.3.3の間には、次のライセンス問題があります:
- ASP.NETプロジェクト
- .NET Frameworkバージョン >= 4.6.2
Web.config ファイルに保存されたキーは、本製品によって検出・使用されることはありません。
回避策
この問題に対処するには、コード内でConfigurationManagerを使用して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ファイルを使用して、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

