Skip to content
Start free evaluation

PDComm.OpcUa.License

Class

Installs and inspects the PDComm license of the OPC UA native library.

public static class License

Client.Discover and Client.Connect need a license for the opcua-client module and Server.Create one for opcua-server. Without it they throw OpcUaException with OpcUaException.LicenseRequired set; clients and servers that already exist keep working.

The library merges the text installed here with the PDCOMM_LICENSE (text) and PDCOMM_LICENSE_FILE (path) environment variables and pdcomm.license files next to the application or the native library and in the user and system configuration directories. The installation belongs to the OPC UA library only. All members are thread-safe.

License.Install(File.ReadAllText("pdcomm.license"));
Console.WriteLine(License.Status().GetProperty("modules").GetProperty("opcua-client").GetProperty("state"));

Members

HostId

Method

Gets the host id of this machine, which host-bound licenses (SECS/GEM runtime licenses) name.

public static string HostId()

Returns

The host id, PDH1-XXXX-XXXX-XXXX-XXXX.

Notes

  • Throws OpcUaException: The machine id cannot be read.
  • Throws TypeInitializationException: The native library is missing or does not implement OPC UA ABI 0.2 (the inner exception says which).

Install

Method

Installs license text, replacing text installed earlier through this method.

public static void Install(string text)

Parameters

NameDescription
textText with one or more -----BEGIN PDCOMM LICENSE----- blocks; text outside the blocks is ignored. An empty string removes the installed text.

Notes

  • Throws ArgumentNullException: text is null.
  • Throws OpcUaException: The text contains no block whose signature verifies, or is larger than 1 MiB; the previous text stays installed.
  • Throws TypeInitializationException: The native library is missing or does not implement OPC UA ABI 0.2 (the inner exception says which).

Status

Method

Gets the license status of the OPC UA library.

public static JsonElement Status()

Returns

A JSON object with host_id, build_date, the found sources, every license block in licenses with its verification, and modules, which maps each module id to its state (licensed, evaluation, missing, expired, not-yet-valid, updates-expired, program-mismatch or host-mismatch), granted and days_left.

Notes

  • Throws OpcUaException: The library could not report its status.
  • Throws TypeInitializationException: The native library is missing or does not implement OPC UA ABI 0.2 (the inner exception says which).