ASP.NET 設定中的 IronWord 授權金鑰

Curtis Chau
Curtis Chau
已更新: 2025年6月10日

問題已在IronWord版本2024.3.5中解決。

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

對於較舊的IronWord版本,特別是在版本2024.3.5之前發布的版本,已知存在授權問題於:

  • ASP.NET項目
  • .NET Framework 版本 >= 4.6.2

儲存在Web.config檔案中的金鑰將無法被產品檢測和使用。

解決方法

為了解決此問題,建議使用 ConfigurationManager 在程式碼中從 Web.config 文件中檢索授權金鑰,然後將其應用於 License.LicenseKey 屬性。

例子:

<configuration>
  ...
  <appSettings>
    <add key="IronWord.LicenseKey" value="IRONWORD.MYLICENSE.KEY.1EF01"/>
  </appSettings>
  ...
</configuration>
XML

使用上面提供的 XML 文件,我們可以使用ConfigurationManager檢索許可證金鑰值並將其傳遞給IronWord.License.LicenseKey屬性。

// Import the necessary namespace for ConfigurationManager
using System.Configuration;

// Retrieve the license key from the AppSettings in Web.config
string licenseKey = ConfigurationManager.AppSettings["IronWord.LicenseKey"];

// Set the license key for IronWord
IronWord.License.LicenseKey = licenseKey;

Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。

閱讀更多

準備好開始了嗎?

NuGet 下載次數 63,050版本:2026.11剛剛發布