IronZIPライセンス設定をweb.configで行う
Curtis Chau
更新日: 2026年7月21日
この問題は2024.3.3以前にリリースされたIronZIPバージョンに影響を与えることが知られています。
注意してください: そのバージョンの発行されたリリースノートは、Web.config/appSettingsでのライセンス修正を特に項目化していないため、2024.3.3以降でもこの例外が見られる場合、以下の回避策が適用されます。
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronZip must be licensed for development.
SHELL
古いIronZIPバージョン、特に2024.3.3以前にリリースされたものには、次のようなライセンスに関する既知の問題があります:
- ASP.NETプロジェクト
- .NET Frameworkバージョン >= 4.6.2
キーはWeb.configファイルに保存されていないと、製品が認識して使用することはありません。
回避策
この問題を解決するためには、コードでConfigurationManagerを使用してWeb.configファイルからライセンスキーを取得し、それをLicense.LicenseKeyプロパティに適用することが推奨されます。
例:
<configuration>
...
<appSettings>
<add key="IronZip.LicenseKey" value="IRONZIP.MYLICENSE.KEY.1EF01"/>
</appSettings>
...
</configuration>
XML
上記の XML ファイルを使用することで、ConfigurationManager を利用してライセンスキーの値を取得し、IronZip.License.LicenseKey プロパティに渡すことができます。
using System;
using System.Configuration;
class Program
{
static void Main()
{
// Retrieve the license key from the web.config appSettings
string licenseKey = ConfigurationManager.AppSettings["IronZip.LicenseKey"];
// Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey;
// Verify that the license key is set properly
Console.WriteLine("License key applied successfully.");
}
}Imports System
Imports System.Configuration
Friend Class Program
Shared Sub Main()
' Retrieve the license key from the web.config appSettings
Dim licenseKey As String = ConfigurationManager.AppSettings("IronZip.LicenseKey")
' Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey
' Verify that the license key is set properly
Console.WriteLine("License key applied successfully.")
End Sub
End ClassImports System
Imports System.Configuration
Friend Class Program
Shared Sub Main()
' Retrieve the license key from the web.config appSettings
Dim licenseKey As String = ConfigurationManager.AppSettings("IronZip.LicenseKey")
' Apply the license key to IronZip
IronZip.License.LicenseKey = licenseKey
' Verify that the license key is set properly
Console.WriteLine("License key applied successfully.")
End Sub
End Classusing System.Configuration;ディレクティブを使用すると、Web.configなどの構成ファイルにアクセスできます。ConfigurationManager.AppSettings["IronZip.LicenseKey"]は、Web.configのappSettingsセクションに保存されたライセンスキーを取得します。IronZip.License.LicenseKey = licenseKey;は取得したキーをIronZIPライブラリに代入し、ライセンス例外を防ぎます。Console.WriteLine()ステートメントは、ライセンスキーの適用プロセスが正常に完了したことを開発者に通知します。
テクニカルライター
Curtis Chauは、カールトン大学でコンピュータサイエンスの学士号を取得し、Node.js、TypeScript、JavaScript、およびReactに精通したフロントエンド開発を専門としています。直感的で美しいユーザーインターフェースを作成することに情熱を持ち、Curtisは現代のフレームワークを用いた開発や、構造の良い視覚的に魅力的なマニュアルの作成を楽しんでいます。