Web.configでライセンスキーを設定する

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

この問題は、 IronQRバージョン2024.3.2解決されました。

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

古い IronQR バージョン、具体的にはバージョン2024.3.2より前にリリースされたバージョンでは、次のライセンスに関する既知の問題があります。

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

Web.config ファイルに保存されたキーは、製品によって取得および使用されません

回避策

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

例:

<configuration>
  ...
  <appSettings>
    <add key="IronQr.LicenseKey" value="IronQR-MYLICENSE-KEY-1EF01"/>
  </appSettings>
  ...
</configuration>
<configuration>
  ...
  <appSettings>
    <add key="IronQr.LicenseKey" value="IronQR-MYLICENSE-KEY-1EF01"/>
  </appSettings>
  ...
</configuration>
XML

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

using System.Configuration;

// Retrieve the license key from the Web.config file's appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronQr.LicenseKey"];

// Apply the retrieved license key to the IronQR LicenseKey property
IronQr.License.LicenseKey = licenseKey;
using System.Configuration;

// Retrieve the license key from the Web.config file's appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronQr.LicenseKey"];

// Apply the retrieved license key to the IronQR LicenseKey property
IronQr.License.LicenseKey = licenseKey;
$vbLabelText   $csharpLabel
カーティス・チャウ
テクニカルライター

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

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

準備はできましたか?
Nuget ダウンロード 62,157 | バージョン: 2026.3 リリース
Still Scrolling Icon

まだスクロールしていますか?

すぐに証拠が欲しいですか? PM > Install-Package IronQR
サンプルを実行する URL が QR コードになるのを見る。