ARSoft.WinFormsLicensing
1.5.4
dotnet add package ARSoft.WinFormsLicensing --version 1.5.4
NuGet\Install-Package ARSoft.WinFormsLicensing -Version 1.5.4
<PackageReference Include="ARSoft.WinFormsLicensing" Version="1.5.4" />
<PackageVersion Include="ARSoft.WinFormsLicensing" Version="1.5.4" />
<PackageReference Include="ARSoft.WinFormsLicensing" />
paket add ARSoft.WinFormsLicensing --version 1.5.4
#r "nuget: ARSoft.WinFormsLicensing, 1.5.4"
#:package ARSoft.WinFormsLicensing@1.5.4
#addin nuget:?package=ARSoft.WinFormsLicensing&version=1.5.4
#tool nuget:?package=ARSoft.WinFormsLicensing&version=1.5.4
ARSoft WinForms Licensing
ARSoft WinForms Licensing is a Windows-focused licensing library for .NET applications. It creates, imports, renews, stores, and validates time-based licenses using encrypted local storage plus Windows Registry redundancy.
Features
- Time-based licenses with configurable validity
- AES encryption with PBKDF2 key derivation
- SHA256 checksum validation for tamper detection
- Dual storage in
%AppData%andHKEY_CURRENT_USER - Automatic repair when either file or registry copy is missing or invalid
- Encrypted
.licfile generation and import - Silent validation mode for client applications
- Optional logging for vendor tools and diagnostics
Installation
Install-Package ARSoft.WinFormsLicensing
dotnet add package ARSoft.WinFormsLicensing
Requirements
- .NET 8
- Windows
Microsoft.Extensions.LoggingNewtonsoft.Json
Setup
Use the same password and salt everywhere: vendor tools, license file generation, and customer applications. If they differ, existing licenses cannot be decrypted.
using System.Text;
var password = "YourSecurePassword123!";
var salt = Encoding.UTF8.GetBytes("YourUniqueSalt12345");
var appName = "MyApplication";
var settingsFile = "license.json";
var registryKeyPath = "SOFTWARE\\MyCompany\\MyApplication\\License";
Create And Store A License
Use ForCreation in vendor tools or admin flows. The logger is optional.
using ARSoft.WinFormsLicensing;
var manager = LicenseManager.ForCreation(
logger: null,
keyPassword: password,
keySalt: salt,
appName: appName,
settingsFile: settingsFile,
registryKeyPath: registryKeyPath);
var created = manager.CreateLicense(
clientName: "Customer ABC",
licensedDate: DateTime.Today,
validityDays: 366,
version: "1.0");
Validate A License
Use ForValidation in customer applications. The logger is optional (pass null for silent mode).
using ARSoft.WinFormsLicensing;
var manager = LicenseManager.ForValidation(
password: password,
salt: salt,
appName: appName,
settingsFile: settingsFile,
registryKeyPath: registryKeyPath,
logger: logger); // optional, defaults to null
var result = manager.ValidateLicense();
if (!result.IsValid)
{
MessageBox.Show(result.Message, "License Validation");
Application.Exit();
}
ValidateLicense() checks both storage locations. If one valid copy exists, the missing or corrupted copy is rebuilt automatically.
Generate A License File
Use LicenseGenerator.GenerateLicenseFile() to create encrypted .lic files for distribution. The logger is optional.
using ARSoft.WinFormsLicensing.Service.Helpers;
var generated = LicenseGenerator.GenerateLicenseFile(
clientName: "Customer ABC",
password: password,
salt: salt,
outputFile: @"C:\licenses\customer-abc.lic",
validityDays: 366,
startDate: DateTime.Today,
version: "1.0",
logger: null);
Import A License File
var imported = manager.ImportLicenseFile(@"C:\licenses\customer-abc.lic");
Renew From License Data
using ARSoft.WinFormsLicensing.Models;
var license = new LicenseData
{
Client = providedClientHash,
Licensed = providedLicensedDate,
Expires = providedExpirationDate,
Version = "1.0",
Checksum = providedChecksum
};
var renewed = manager.RenewLicense(license);
Storage
| Location | Path |
|---|---|
| File | %AppData%\[AppName]\[SettingsFile] |
| Registry | HKEY_CURRENT_USER\[RegistryKeyPath] |
settingsFile can also be an absolute path. Relative file names are stored under %AppData%\[AppName].
Main API
| Member | Description |
|---|---|
LicenseManager.ForCreation() |
Creates a manager for license creation, renewal, import, and validation. Accepts a nullable logger. |
LicenseManager.ForValidation() |
Creates a manager for customer application validation. Accepts a nullable logger. |
CreateLicense() |
Creates and stores a license in both storage locations. |
ValidateLicense() |
Validates checksum, expiration, and storage consistency. |
IsLicensePresent() |
Returns true when a license can be loaded from file or registry. |
LoadValidLicense() |
Loads the first available license copy. |
ImportLicenseFile() |
Imports an encrypted .lic file and stores it locally. |
RenewLicense() |
Stores a new license after checksum validation. |
RenewLicenseFromString() |
Renews from encrypted license text. |
RenewLicenseFromFile() |
Renews from an encrypted license file. |
LicenseGenerator.GenerateLicenseFile() |
Creates an encrypted .lic file. Accepts an optional logger. |
LoggerEnabled |
Enables or disables the configured logger at runtime. |
Validation Messages
| Scenario | Message |
|---|---|
| Missing or corrupted license | Licença não encontrada ou corrompida. |
| Expired license | Licença expirada. |
| Last valid day | Hoje é o último dia da licença. |
| One day remaining | Resta 1 dia até o término da licença. |
| Up to 31 days remaining | Restam [days] dias até o término da licença. |
Security Notes
- Use a strong password.
- Use a unique salt per application.
- Keep password and salt consistent across all tools for the same product.
- Distribute
.licfiles through a trusted channel. - Validate licenses at startup and before sensitive workflows.
- Registry paths must start with
SOFTWARE\.
Version History
v1.5.3
- Added optional
ILoggerparameter toLicenseManager.ForValidation()for diagnostics in client applications - Added optional
ILoggerparameter toLicenseGenerator.GenerateLicenseFile()for logging during file generation - Logger is now available across all library entry points (
ForCreation,ForValidation,LicenseGenerator)
v1.5.2
- Fixed
ForValidation()file lookup so it uses the same%AppData%\[AppName]\[SettingsFile]path asForCreation() - Fixed nullable logger support in
ForCreation() - Added argument validation for app name, settings file, registry path, password, salt, and version
- Added fixed-time checksum comparison
- Added invariant client hashing
- Added output directory creation for license file generation
- Added xUnit coverage for creation, validation, import, and checksum rejection
- Updated package metadata and documentation
v1.5.1
- Removed parameterless
ForValidation()method - Required password and salt for validation
- Unified encryption parameters between creation and validation modes
v1.5.0
- Added optional logger behavior
- Added
LoggerEnabled
v1.4.0
- Added
ImportLicenseFile() - Added
LicenseGenerator
v1.3.0
- Made
LicenseUtilspublic - Improved validation and error handling
v1.2.0
- Added factory methods
- Added
IsLicensePresent() - Added
LoadValidLicense()
v1.0.0
- Initial release
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0-windows10.0.17763 is compatible. net9.0-windows was computed. net10.0-windows was computed. |
-
net8.0-windows10.0.17763
- Microsoft.Extensions.Logging (>= 9.0.9)
- Newtonsoft.Json (>= 13.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.