在web.config(C#)中配置IronXL授權
Curtis Chau
Updated: 2026年5月9日
問題已在IronXL版本2024.3.20中解決。
Exception: Unhandled exception. IronSoftware.Exceptions.LicensingException: IronXL must be licensed for development.
Text
對於舊版IronXL,特別是版本2023.4.13至2024.3.20之間的版本,已知在以下情況存在授權問題:
- ASP.NET專案
- .NET Framework version >= 4.6.2
儲存在Web.config文件中的金鑰將無法被產品拾取並使用。
替代方案
為了解決此問題,建議從License.LicenseKey屬性。
範例:
以下是如何在Web.config文件中儲存授權金鑰的範例:
<configuration>
...
<appSettings>
<add key="IronXL.LicenseKey" value="IronXL-MYLICENSE-KEY-1EF01"/>
</appSettings>
...
</configuration>
XML
使用上述XML文件設置,我們可以使用ConfigurationManager來擷取授權金鑰值,並將其設置到IronXL.License.LicenseKey屬性:
using System.Configuration;
// Retrieve the license key from the Web.config appSettings section
string licenseKey = ConfigurationManager.AppSettings["IronXL.LicenseKey"];
// Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey;Imports System.Configuration
' Retrieve the license key from the Web.config appSettings section
Dim licenseKey As String = ConfigurationManager.AppSettings("IronXL.LicenseKey")
' Apply the retrieved license key to the IronXL component
IronXL.License.LicenseKey = licenseKey在此範例中,使用IronXL.LicenseKey的值。 然後將擷取的授權金鑰設置到IronXL.License.LicenseKey中,以確保IronXL元件能夠正常運行。

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