IRONSOFTWAREHOME

web.config 中的 IronOCR 授權設定

Curtis Chau
Curtis Chau
Updated: 2026年4月22日

此問題已於 IronZip 版本 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 檔案中的金鑰,將不會被產品讀取並使用。

解決方案

為解決此問題,建議在程式碼中使用 ConfigurationManagerWeb.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.");
    }
}
  • using System.Configuration; 指令可存取設定檔,例如 Web.config
  • ConfigurationManager.AppSettings["IronZip.LicenseKey"] 會從 appSettings 區段中讀取 Web.config 所儲存的授權金鑰。
  • IronZip.License.LicenseKey = licenseKey; 會將擷取到的金鑰指派給 IronZIP程式庫,以避免觸發授權例外狀況。
  • Console.WriteLine() 語句會向開發人員回報,表示授權金鑰申請流程已成功完成。
Curtis Chau
技術作家

Curtis Chau擁有Carleton大學的電腦科學學士學位,專精於前端開發,擁有Node.js、TypeScript、JavaScript和React的專業知識。Curtis熱衷於建立直觀且美觀的使用者介面,喜愛使用現代框架並建立結構良好、視覺吸引力的手冊。

...
閱讀更多

準備好要開始了嗎?

Nuget Downloads 23,187版本:2026.9剛剛發布

立即獲取您的免費30天試用金鑰
無需信用卡或建立帳戶
C# NuGet PDF程式庫
NuGet安裝

版本: 2026.9

PM > Install-Package IronZip
nuget.org/packages/IronZip/
  1. 在方案資源管理器中,右鍵點擊參考,管理NuGet包
  2. 選擇“瀏覽”並搜尋“IronZip”
  3. 選擇套件並安裝
C# PDF DLL
立即下載DLL

版本: 2026.9

  1. 下載並解壓縮IronZIP到您的方案目錄下,例如~/Libs
  2. 在Visual Studio方案資源管理器中,右鍵點擊參考。選擇瀏覽,“IronZip.dll”

授權從$999

有問題?聯絡我們的開發團隊。

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
預約您的免費即時演示
Booking Badge

受到全球數百萬工程師的信賴

Iron Software的客戶標誌
獲取您的無需承諾咨詢
完成以下表格或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終被保密。
受到全球數百萬工程師的信賴
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立