Konfiguracja licencji IronBarcode w web.config

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

Ten problem został rozwiązany w wersji 2024.3.2 IronBarcode.

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

Dla starszych wersji IronBarcode, w szczególności tych pomiędzy wersjami 2023.4.1 a 2024.3.2, istnieje znany problem z licencjonowaniem w:

  • projektach ASP.NET
  • wersjach .NET Framework >= 4.6.2

Klucz przechowywany w pliku Web.config NIE zostanie wykryty i użyty przez produkt.

Obejście

Aby rozwiązać ten problem, zaleca się pobranie klucza licencji z pliku Web.config przy użyciu ConfigurationManager w kodzie, a następnie zastosowanie go do właściwości License.LicenseKey.

Przykład:

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

Z dostarczonym powyżej plikiem XML możemy użyć ConfigurationManager do pobrania wartości klucza licencji i przekazania jej do właściwości IronBarCode.License.LicenseKey.

using System.Configuration;
// Retrieve the license key from appSettings in the Web.config file
string licenseKey = ConfigurationManager.AppSettings["IronBarCode.LicenseKey"];

// Apply the retrieved license key to the IronBarCode LicenseKey property
IronBarCode.License.LicenseKey = licenseKey;
using System.Configuration;
// Retrieve the license key from appSettings in the Web.config file
string licenseKey = ConfigurationManager.AppSettings["IronBarCode.LicenseKey"];

// Apply the retrieved license key to the IronBarCode LicenseKey property
IronBarCode.License.LicenseKey = licenseKey;
Imports System.Configuration
' Retrieve the license key from appSettings in the Web.config file
Private licenseKey As String = ConfigurationManager.AppSettings("IronBarCode.LicenseKey")

' Apply the retrieved license key to the IronBarCode LicenseKey property
IronBarCode.License.LicenseKey = licenseKey
$vbLabelText   $csharpLabel
Curtis Chau
Autor tekstów technicznych

Curtis Chau posiada tytuł licencjata z informatyki (Uniwersytet Carleton) i specjalizuje się w front-endowym rozwoju, z ekspertką w Node.js, TypeScript, JavaScript i React. Pasjonuje się tworzeniem intuicyjnych i estetycznie przyjemnych interfejsów użytkownika, Curtis cieszy się pracą z nowoczesnymi frameworkami i tworzeniem dobrze zorganizowanych, atrakcyjnych wizualnie podrę...

Czytaj więcej
Gotowy, aby rozpocząć?
Nuget Pliki do pobrania 2,145,441 | Wersja: 2026.4 just released
Still Scrolling Icon

Wciąż przewijasz?

Czy chcesz szybko dowodu? PM > Install-Package BarCode
uruchom przykład zobacz, jak twoje ciągi zamieniają się w kody kreskowe.