How to add license keys to a .NET application
Install the NuGet package, bind the first activation to a device, validate the correct product on startup, and sell the finished application without building a separate checkout.
dotnet add package PermitCore.Client
using PermitCore;
using System.Reflection;
var client = new PermitCoreClient("https://api.permitcore.dev");
var version = Assembly.GetEntryAssembly()?.GetName().Version?.ToString() ?? "1.0.0";
var result = await client.ValidateAsync(
licenseKey,
version: version,
expectedProductId: productId);
if (!result.IsValid)
return ShowActivationWindow(result.Message);From product record to paid customer
Use PermitCore for the licensing layer and the sale. Your customer checks out in your branded Store and receives a working license automatically.
- 01Create
Create the product and license policy
In Products, create the software your key unlocks. Choose its activation limit, validity, offline grace period, version range, and feature flags.
- Create the desktop product
- Set activation and version limits
- Choose an offline grace period
- Copy the product ID
- 02Implement
Install the .NET SDK and scope the key
Put license activation in the first-run flow and validation at startup. Pass your product ID so a valid key for another product cannot unlock this one.
dotnet add package PermitCore.Client- Activate on the first successful entry
- Validate at application startup
- Pass expectedProductId on every check
- Use feature flags for paid capabilities
- 03Verify
Test the real validation path
Create a short-lived test license and exercise valid, expired, revoked, and wrong-product states. When offline grace is enabled, the SDK falls back to its signed cached response if the server cannot be reached.
- 04Sell
Publish the product in your Store
Connect your Stripe account, add the product to your branded PermitCore Store, and publish. Checkout creates the license and delivers it to the customer without a webhook project or a second commerce platform.
- Create the matching Store product
- Use one-time or recurring Stripe pricing
- Let checkout issue the license
- Verify the customer's delivery email
One checkout completes the sale and delivers the license.
.NET production checklist
The sample is intentionally small. Add these safeguards before making licensing part of a paid release.
- Store only the customer's license key on the device, never an Admin credential.
- Handle WrongProduct separately from a malformed or revoked key.
- Show a clear offline-grace state instead of treating it as a fresh online result.
- Test activation release and transfer before shipping paid builds.