1. Prepare product settings and a test license
Add customer license keys and feature permissions to your C#/.NET or WinForms application. This guide covers access to your commercial software; choosing an open-source license for your code is a separate decision. Start with a device-bound license and an unmetered export feature.
Device quota counts current activations and is returned on release. Ordinary licenses remain counted while offline; floating licenses also return quota when their leases expire.
- Copy the Product ID from Console > Products. Open that product’s Signing public keys and paste every key ID/public key pair into the initialization code, replacing YOUR_PRODUCT_ID, YOUR_KEY_ID and YOUR_PUBLIC_KEY. Quick integration can generate these public code constants. No product configuration file is required; the SDK defaults to https://www.licentivo.com.
- Install the .NET 8 SDK or later. In Licentivo Quick integration, create or select your product and allow the export feature in its policy and license.
2. Install the pinned .NET package
Run the command below in your application project, or add the build dependency, to install SDK 0.11.6. The package manager retrieves the SDK; no source ZIP, manual extraction or local source path is required.
dotnet add package Licentivo.SDK --version 0.11.6dotnet new console --name LicensedApp --framework net8.0
cd LicensedApp
dotnet add package Licentivo.SDK --version 0.11.63. Activate and protect one real operation
Move SDK startup into your application’s startup or activation handler. Read the customer key from your activation form, pass your own product ID and trusted keys, and keep the client alive until shutdown. Put RunFeature at the actual business entry point; replace the report writer with your own operation.
using Licentivo;
// BEGIN LICENTIVO PRODUCT
// Copy Product ID and all key ID/public key pairs from Console > Products > Signing public keys.
const string ProductId = "YOUR_PRODUCT_ID";
var TrustedKeys = new Dictionary<string,string> { ["YOUR_KEY_ID"] = "YOUR_PUBLIC_KEY" };
// END LICENTIVO PRODUCT
static string Setting(string name, string fallback) => Environment.GetEnvironmentVariable(name) ?? fallback;
// Call at the business entry point, including shortcuts and alternate menu actions.
static async Task ExportReport(string path)
{
// Replace this write with your existing, non-metered export operation.
await File.WriteAllTextAsync(path, "A report generated by the licensed application.\n");
}
try
{
// In a GUI, read the activation input. Later starts pass an empty key.
await using var client = await LicentivoClient.OpenProduct(
ProductId, TrustedKeys, Setting("LICENTIVO_LICENSE_KEY", ""),
error => Console.Error.WriteLine($"Background verification: {error.Message}"));
var feature = Setting("LICENTIVO_FEATURE", "export");
var path = Setting("LICENTIVO_OUTPUT", "licensed-report.txt");
if (Setting("LICENTIVO_METERED", "") == "1")
await client.RunMeteredFeature(feature, 1, Setting("LICENTIVO_OPERATION_ID", ""), () => ExportReport(path));
else
await client.RunFeature(feature, () => ExportReport(path));
Console.WriteLine($"License OK: {feature} is available\nExport completed: {path}");
// Keep client alive in your real app; disposal belongs in app shutdown.
}
catch (Exception error)
{
Console.Error.WriteLine(error.Message);
Environment.ExitCode = 2;
}
$env:LICENTIVO_LICENSE_KEY = 'YOUR_TEST_LICENSE_KEY'
dotnet run
# On later starts, restore the saved device credential:
Remove-Item Env:LICENTIVO_LICENSE_KEY
dotnet runexport LICENTIVO_LICENSE_KEY='YOUR_TEST_LICENSE_KEY'
dotnet run
# On later starts, restore the saved device credential:
unset LICENTIVO_LICENSE_KEY
dotnet run4. Connect activation and export to WinForms
In every export entry point, await client.RunFeature("export", ExportReport). Include menu items and shortcuts. Disable the initiating button while an operation runs, catch errors and show the denial before allowing another attempt.
Keep the client alive while the window is open so SDK heartbeats can refresh authorization. Marshal background error messages onto the UI thread with Invoke or BeginInvoke. Await DisposeAsync at application shutdown; normal disposal retains a device-bound registration and attempts to return a floating seat.
A separate desktop example is available through the documentation link below. WinForms requires Windows; the console example above also runs on Linux and macOS.
dotnet new winforms --name LicensedWinForms --framework net8.0
cd LicensedWinForms
dotnet add package Licentivo.SDK --version 0.11.6using Licentivo;
namespace LicensedWinForms;
sealed class DemoForm : Form {
// BEGIN LICENTIVO PRODUCT
// Console > Products > Signing public keys: paste Product ID and every key ID/public key pair.
const string ProductId = "YOUR_PRODUCT_ID";
static readonly Dictionary<string,string> TrustedKeys = new() { ["YOUR_KEY_ID"] = "YOUR_PUBLIC_KEY" };
// END LICENTIVO PRODUCT
readonly TextBox key = new() { Width = 380, UseSystemPasswordChar = true };
readonly Label status = new() { AutoSize = true, MaximumSize = new Size(550, 0), Text = "Enter a key, or leave empty to restore this device." };
readonly CancellationTokenSource lifetime = new();
LicentivoClient? client;
bool busy;
[STAThread] static void Main() { ApplicationConfiguration.Initialize(); Application.Run(new DemoForm()); }
DemoForm() {
Text = "Licentivo · Report export"; ClientSize = new Size(600, 220);
var panel = new FlowLayoutPanel { Dock = DockStyle.Fill, Padding = new Padding(20), FlowDirection = FlowDirection.TopDown, WrapContents = false, AutoScroll = true };
Controls.Add(panel); panel.Controls.Add(new Label { Text = "Customer license key", AutoSize = true }); panel.Controls.Add(key);
Add(panel, "Activate / restore", async () => {
if (client is not null) { await client.DisposeAsync(); client = null; }
client = await LicentivoClient.OpenProduct(ProductId, TrustedKeys, key.Text, ct: lifetime.Token);
key.Clear(); status.Text = client.Status().State;
});
var buttons = new FlowLayoutPanel { AutoSize = true, AutoSizeMode = AutoSizeMode.GrowAndShrink, WrapContents = false }; panel.Controls.Add(buttons);
Add(buttons, "Export CSV", () => Export("export", "report.csv"));
Add(buttons, "Pro export", () => Export("pro", "pro-report.csv"));
Add(buttons, "Refresh license", async () => { await Require().RefreshOnline(lifetime.Token); status.Text = Require().Status().State; });
panel.Controls.Add(status);
FormClosed += async (_, _) => { lifetime.Cancel(); if (client is not null) await client.DisposeAsync(); };
}
LicentivoClient Require() => client ?? throw new InvalidOperationException("Activate the application first.");
async Task Export(string feature, string filename) {
using var save = new SaveFileDialog { FileName = filename, Filter = "CSV report|*.csv" };
await Require().RunFeature(feature, async () => {
if (save.ShowDialog(this) != DialogResult.OK) return;
await File.WriteAllTextAsync(save.FileName, "Item,Quantity,Price\nNotebook,2,12.50\nPen,5,3.00\n");
status.Text = "Saved: " + save.FileName;
});
}
void Add(Control panel, string title, Func<Task> action) {
var button = new Button { Text = title, AutoSize = true }; panel.Controls.Add(button);
button.Click += async (_, _) => {
if (busy) return; busy = true; status.Text = "Working…";
try { await action(); } catch (Exception error) { if (!IsDisposed) status.Text = error.Message; }
finally { busy = false; }
};
}
}
dotnet run5. Verify activation, restart and denial
- Run with your test key and confirm License OK and Export completed, then inspect the report contents.
- Remove the key environment variable and restart under the same operating-system user. The existing device credential should restore without a new registered device.
- Use LICENTIVO_FEATURE to select a feature absent from the license and LICENTIVO_OUTPUT to select a fresh filename. Confirm a nonzero exit code and that this new file is never created.
- Check offline startup only with a policy that permits it and a valid signed cache. Floating and online-only startup require server approval.
Troubleshoot license checks
Check the product ID, every key ID/public key pair and the customer’s license input. Public verification keys belong to a product; customer licenses and saved device credentials are separate. Do not distribute development test keys or vendor management API keys.
An expired license, device limit or missing feature is an authorization denial. Show the error and request ID, and resolve the license or policy in the console instead of bypassing RunFeature.
For monthly usage limits, retain a stable job ID and durable business result when calling RunMeteredFeature. Normal app shutdown and customer-requested Deactivate have different purposes; do not release a device-bound registration on every exit.