Configuring the Activation

The license is represented by the Activation object, and there should be only a single instance of the Activation class created for every seat in your app (usually only one, in case your application needs to hold multiple activation instances for more products, see "Multiple Activations Support" page). The state of the Activation can be accessed through the Activation.State property.

Configure Activation instance

The following command will create a new instance of the Activation object in Uninitialized state. Before configuring the activation, collect the Tenant ID and Licensing API URL from the Account -> API Credentials page in the UI.

var activation = new Activation(options => 
  { // configure the options by following the instructions below });

There are the following configuration options available:

  • Tenant ID - ID of the tenant. Can be retrieved from the API Credentials page.


  • Product ID - the product for which we are implementing the licensing.


Remember that each "product" has its own unique ID. You will need to use different IDs for every product you release.

  • Seat ID - represents the machine, the user, or some other element which the license should be linked with. Because the seat ID usually depends on the information, which is only available at runtime, it is configured as a callback.

    options.WithSeatId(() => YourSeatIdFunction())

  • Storage - holds the licensing data, which needs to be persisted on the machine, where your application is running. In the case of the desktop application, the usual choice is a file and that's why we are providing a FileStorage in our SDK, which you can use from the start. Please note that the data in our FileStorage implementation are not encrypted, which allows the user to manipulate and export the licensing data.

    Depending on your use case, we recommend to use your own storage by implementing the IActivationStorage interface, using the database, filesystem, or other persistence mechanism most suitable for your app.

    options.WithStorage(new FileActivationStorage("pathToTheFile"))

  • Online Activation - allows the license activation when there is a network connection to the Licensing server. For the online activation, the following options need to be configured:

    • Licensing API URL - Licensing API base URL

    • HTTP Client Factory - HttpClient callback providing an HTTP Client for executing the Licensing API calls. The factory method enables the implementation of the proper HTTP Client's lifetime management, depending on your app's type. See the Guidelines for using HttpClient for more details.

      options.WithOnlineActivationSupport(online => 
              online.UseLicensingApi(new Uri(licensingApiUrl))
                    .UseHttpClientFactory(() => httpClientFactory.CreateClient()))

  • Offline Activation - for the rare cases, when there is a machine without a network connection, but the license needs to be activated anyway, offline activation support can be added to your application. For the offline activation, a tenant's public RSA key needs to be provided to the client configuration. It's required to verify the integrity and authenticity of the offline tokens, which are being provided by the end user to your application.

    options.WithOfflineActivationSupport(offline => 
            offline.UseTenantPublicKey(new JsonWebKey {
                                              Alg = "RSA",
                                              N = yourTenantKeyModulus,
                                              E = "AQAB" }))
  • Logging - to have access to the SDK's logs, your logger factory implementing the ILoggerFactory interface can be plugged in.

    options.UseLoggerFactory(new YourLoggerFactory())
  • Activation Operation Lock - the Activation class uses a locking mechanism that makes it thread-safe and prevents the parallel execution of multiple activation methods, which might lead to an inconsistent activation state. The default lock leverages SemaphoreSlim, but if you need a custom locking mechanism, you can provide your own implementation of the IActivationOperationLock interface.

    options.UseActivationOperationLock(new YourActivationOperationLock())

  • State Transition Callback - if you want to "hook your own code" into the activation's state transition logic, you can define a callback, which is executed after the state has been changed.

    options.UseStateTransitionCallback((oldState, updatedActivation) =>
        Console.WriteLine($"Activation state changed from {oldState} to {updatedActivation.State}");
        return Task.CompletedTask;

Last updated


Service terms

© Copyright - Nalpeiron, all rights reserved Website use subject to Terms and Conditions. See our Privacy Policy Use of Zentitle is subject to our Service Terms and Conditions