Standard.Licensing 1.3.0

dotnet add package Standard.Licensing --version 1.3.0
                    
NuGet\Install-Package Standard.Licensing -Version 1.3.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Standard.Licensing" Version="1.3.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Standard.Licensing" Version="1.3.0" />
                    
Directory.Packages.props
<PackageReference Include="Standard.Licensing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Standard.Licensing --version 1.3.0
                    
#r "nuget: Standard.Licensing, 1.3.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Standard.Licensing@1.3.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Standard.Licensing&version=1.3.0
                    
Install as a Cake Addin
#tool nuget:?package=Standard.Licensing&version=1.3.0
                    
Install as a Cake Tool

Standard.Licensing Logo

Standard.Licensing

Easy-to-use licensing library for .NET and .NET Framework products.

Standard.Licensing on GitHub Standard.Licensing latest version on NuGet Standard.Licensing total downloads on NuGet Buy me a coffee


Installation

Get Standard.Licensing from NuGet.

dotnet add package Standard.Licensing

Usage

Create a private and public key for your product

Standard.Licensing uses the Elliptic Curve Digital Signature Algorithm (ECDSA) to ensure the license cannot be altered after creation.

First you need to create a new public/private key pair for your product:

var keyGenerator = Standard.Licensing.Security.Cryptography.KeyGenerator.Create(); 
var keyPair = keyGenerator.GenerateKeyPair(); 
var privateKey = keyPair.ToEncryptedPrivateKeyString(passPhrase);  
var publicKey = keyPair.ToPublicKeyString();

Store the private key securely and distribute the public key with your product. Normally you create one key pair for each product, otherwise it is possible to use a license with all products using the same key pair. If you want your customer to buy a new license on each major release you can create a key pair for each release and product.

Create the license generator

Now we need something to generate licenses. This could be easily done with the LicenseFactory:

var license = License.New()  
    .WithUniqueIdentifier(Guid.NewGuid())  
    .As(LicenseType.Trial)  
    .ExpiresAt(DateTime.Now.AddDays(30))  
    .WithMaximumUtilization(5)  
    .WithProductFeatures(new Dictionary<string, string>  
        {  
            {"Sales Module", "yes"},  
            {"Purchase Module", "yes"},  
            {"Maximum Transactions", "10000"}  
        })  
    .LicensedTo("John Doe", "john.doe@example.com")  
    .CreateAndSignWithPrivateKey(privateKey, passPhrase);

Now you can take the license and save it to a file:

File.WriteAllText("License.lic", license.ToString(), Encoding.UTF8);

or

license.Save(xmlWriter);

Validate the license in your application

The easiest way to assert the license is in the entry point of your application.

First load the license from a file or resource:

var license = License.Load(...);

Then you can assert the license:

using Standard.Licensing.Validation;

var validationFailures = license.Validate()  
                                .ExpirationDate(systemDateTime: DateTime.Now)  
                                .When(lic => lic.Type == LicenseType.Trial)  
                                .And()  
                                .Signature(publicKey)  
                                .AssertValidLicense();

Standard.Licensing will not throw any Exception and just return an enumeration of validation failures.

Now you can iterate over possible validation failures:

foreach (var failure in validationFailures)
     Console.WriteLine(failure.GetType().Name + ": " + failure.Message + " - " + failure.HowToResolve);

Or simply check if there is any failure:

if (validationFailures.Any())
   // ...

Make sure to call validationFailures.ToList() or validationFailures.ToArray() before using the result multiple times.

Third Party Projects

Credits

This is project is derived from Portable.Licensing library. The purpose of this fork is to add support for more .NET platforms, especially .NET Standard and .NET Core.

License

This project is licensed under MIT License.


Made with ☕ by Junian.dev.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 is compatible.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (39)

Showing the top 5 NuGet packages that depend on Standard.Licensing:

Package Downloads
uMarketingSuite.Core

The all-in-one marketing solution for the Umbraco CMS - assemblies only

LicenseManager_12noon.Client

This NuGet package enables a .NET application to use a simplified API for validating a license. It is forked from the Standard.Licensing project and fixes some of its issues. It is also an optional companion to the 12noon License Manager X application.

YoyoBoot.Core

Package Description

TrustImage.TiibSigner

Trustimage.TiibSigner é um pacote para assinatura de documento pdf com certificado digital.

Flowcourier.Umbraco.Analytics

An Umbraco plugin that empowers editors to access Analytics statistics data directly from Umbraco backoffice

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.0 90 7/23/2026
1.2.2 52,168 1/4/2026
1.2.1 189,142 11/14/2024
1.2.0 72,680 7/30/2024
1.1.9 23,381 6/9/2024
1.1.8 59,753 4/27/2024
1.1.5 1,761,494 2/17/2018

Standard.Licensing Release Notes

1.3.0 - 2026-05-06
* Changed: Normalize license expiration to UTC and compare calendar dates only, preventing time-zone and time-of-day expiration errors.
* Added: Support for .NET Framework 4.8.1.

1.2.2 - 2026-01-04
* Added: Support for .NET 10.

1.2.1 - 2024-11-14
* Added: Support for .NET 9.

1.2.0 - 2024-07-31
* Changed: Replaced bundled BouncyCastle sources with the BouncyCastle.Cryptography package.
* Changed: Limited supported target frameworks to .NET 6+, .NET Standard 2.0, and .NET Framework 4.6.1.

1.1.9 - 2024-06-09
* Added: Allow callers to supply a custom date when validating license expiration.
* Fixed: Avoid multiple enumeration during AssertValidLicense validation.

1.1.8 - 2024-04-27
* Fixed: Correct validation-chain behavior for validation lists.

1.1.7 - 2024-01-04
* Changed: Updated BouncyCastle dependency support and included the test project.

1.1.6 - 2024-01-04
* Added: Support for .NET 6 and .NET 8.
* Removed: Portable Class Library target support.

1.1.5 - 2018-02-17
* Changed: Migrated the library and tests to the Standard.Licensing .NET Standard project structure.