.NET SDK

Official SDKs

.NET SDK

The official .NET client targets .NET 6, 7, 8, 9, and 10. Zero dependencies.

Installation

Package Manager
dotnet add package PermitCore.Client

Quick start — validate on every launch

C#
using PermitCore;

var client = new PermitCoreClient("https://api.permitcore.dev");
var result = await client.ValidateAsync(
    "PERMIT-XXXX-XXXX-XXXX-XXXX",
    expectedProductId: Guid.Parse("7f3e9a2b-1c4d-4e8f-9a6b-3d2c1e0f5a8b")); // Optional — reject a key issued for a different product instead of silently accepting it

if (result.ErrorCode == "WrongProduct")
{
    MessageBox.Show($"This key is for a different product: {result.ProductId}");
    Application.Exit();
    return;
}
if (!result.IsValid)
{
    MessageBox.Show($"License invalid: {result.Message}");
    Application.Exit();
    return;
}

// Unlock features based on flags
if (result.HasFeature("export")) EnableExportMenu();
if (result.IsTrial)
    ShowTrialBanner($"{result.TrialDaysRemaining} days remaining");

// Warn if vendor subscription is expiring
if (result.VendorWarning is not null)
    ShowStatusWarning(result.VendorWarning);

Activation (first install)

C#
// Call once when the user first installs on a new machine
var result = await client.ActivateAsync(
    licenseKey:  "PERMIT-XXXX-XXXX-XXXX-XXXX",
    deviceId:    PermitCoreClient.GetHardwareId(), // auto-generated HWID
    deviceName:  Environment.MachineName,
    expectedProductId: Guid.Parse("7f3e9a2b-1c4d-4e8f-9a6b-3d2c1e0f5a8b") // Optional — reject a key issued for a different product
);

if (result.IsValid)
    SaveActivationSuccess();
else if (result.ErrorCode == "WrongProduct")
    ShowError($"Wrong product: {result.ProductId}");
else
    ShowError($"Could not activate: {result.Message}");

Product scoping: by default, any active key belonging to your tenant validates/activates successfully regardless of which product it was issued for. If you sell more than one product, either check result.ProductId yourself, or pass the optional expectedProductId parameter and let the server reject a mismatch (result.ErrorCode == "WrongProduct"). Find a product's ID in the Admin panel under Products.

Offline mode

When the server is unreachable, the SDK automatically returns the last cached response for offlineGraceDays days. Enable/disable in options:

C#
var client = new PermitCoreClient(new PermitCoreOptions
{
    BaseUrl            = "https://api.permitcore.dev",
    EnableOfflineCache = true,  // default
});

var result = await client.ValidateAsync(key);
if (result.IsOffline)
    ShowStatusBar("Running in offline mode");

Floating licenses

Check out a seat when the session starts. While running, heartbeat about every four minutes and handle failed heartbeats. Stop using a rejected session. Cancel the heartbeat loop and await checkin during normal shutdown; process-exit callbacks may not finish network calls. See floating-session lifecycle.