Your .NET app needs to know: Is there a valid license on this computer?
Here's how to check in 5 lines.
The Code
using QLM.LicenseLib;
var lv = new LicenseValidator("settings.xml");
bool needsActivation = false;
string errorMsg = string.Empty;
bool isActivated = lv.ValidateLicenseAtStartup(
ELicenseBinding.ComputerName,
ref needsActivation,
ref errorMsg
);
if (isActivated)
{
Console.WriteLine("License is valid - app can run");
}
else
{
Console.WriteLine("No valid license: " + errorMsg);
}
That's it. 5 lines.
What ValidateLicenseAtStartup Does
- Looks for stored license on the computer
- Validates signature (RSA-2048)
- Checks expiry (for trials/subscriptions)
- Optionally contacts server (if online validation enabled)
- Returns true/false
Three Possible Outcomes
1. License is valid (isActivated = true)
if (isActivated)
{
RunApp();
}
2. No license found (needsActivation = true)
if (needsActivation)
{
ShowActivationDialog();
}
3. License exists but invalid (isActivated = false)
if (!isActivated)
{
Console.WriteLine("Error: " + errorMsg);
// Expired, wrong version, revoked, etc.
}
Real Example: Desktop App
using System;
using QLM.LicenseLib;
class Program
{
static void Main(string[] args)
{
if (IsLicenseActivated())
{
Console.WriteLine("Starting application...");
RunApp();
}
else
{
Console.WriteLine("Please activate your license.");
}
}
static bool IsLicenseActivated()
{
var lv = new LicenseValidator("settings.xml");
bool needsActivation = false;
string errorMsg = string.Empty;
bool isValid = lv.ValidateLicenseAtStartup(
ELicenseBinding.ComputerName,
ref needsActivation,
ref errorMsg
);
if (needsActivation)
{
Console.WriteLine("No license found - activation required");
return false;
}
if (!isValid)
{
Console.WriteLine($"License invalid: {errorMsg}");
return false;
}
return true;
}
static void RunApp()
{
Console.WriteLine("App is running with valid license");
// Your application code here
}
}
Different License Types
This works for all license types:
Permanent licenses:
- No expiry date
- Valid forever
Trial licenses:
- Expires after X days
-
ValidateLicenseAtStartupreturns false after expiry
Subscription licenses:
- Renews periodically
- Auto-extends when customer pays
Hardware Binding
You can bind licenses to different identifiers:
// Computer Name (default)
lv.ValidateLicenseAtStartup(
ELicenseBinding.ComputerName,
ref needsActivation,
ref errorMsg
);
// MAC Address
lv.ValidateLicenseAtStartup(
ELicenseBinding.MacAddress,
ref needsActivation,
ref errorMsg
);
// Motherboard Serial
lv.ValidateLicenseAtStartup(
ELicenseBinding.MotherboardSerialNumber,
ref needsActivation,
ref errorMsg
);
Most common: ComputerName (easy for users)
Most secure: MotherboardSerialNumber (survives OS reinstalls)
Offline vs Online Validation
Offline (default):
- Validates license signature locally
- Checks expiry date
- No internet required
Online (optional):
- Contacts QLM License Server
- Detects revoked licenses
- Checks for subscription renewals
Enable online validation:
lv.QlmLicenseObject.ValidateOnServer = true;
When to Call This
At application startup:
static void Main(string[] args)
{
if (!IsLicenseActivated())
{
Environment.Exit(0);
}
RunApp();
}
Before accessing paid features:
public void UnlockPremiumFeature()
{
if (!IsLicenseActivated())
{
MessageBox.Show("This feature requires a license");
return;
}
// Premium feature code
}
Error Messages
Common errorMsg values:
-
"The license key is invalid"→ Wrong key or signature -
"The license has expired"→ Trial/subscription ended -
"The license is disabled"→ Revoked by admin -
"The product version is incorrect"→ License for different version
Supported Platforms
- Windows: .NET Framework 2.x / 4.x, .NET 6/7/8/9/10
- Cross-platform: .NET 6/7/8/9/10 (macOS, Linux)
- Mobile: Android, iOS (.NET MAUI, Xamarin)
Quick License Manager
This uses Quick License Manager (QLM).
Pricing (per developer):
- QLM Express: $200/year
- QLM Professional: $699/year
- QLM Enterprise: $999/year
Features:
- RSA-2048 + AES-256 encryption
- Online & offline activation
- Trial & subscription support
- 12 e-commerce integrations
- Customer self-service portal
- Floating licenses (Enterprise)
Resources
Related articles:
Questions? Drop them in the comments! 👇
Quick License Manager by Soraco Technologies — https://soraco.co
Top comments (0)