The .NET binding is a single NuGet package that carries the native library for you, so there is no “copy this DLL next to your executable” step and no architecture guessing.
dotnet add package KeyNub.LicenseDongleCode language: Bash (bash)
Reading a license
using KeyNub.LicenseDongle;
using var dongle = Dongle.Open(); // first dongle found
if (!dongle.IsGenuine)
return LicenseResult.NotGenuine;
dongle.SessionOpen();
byte[] license = dongle.RecordRead("license");Code language: C# (cs)
Dongle is IDisposable, so a using declaration closes the device on every exit path, including exceptions. That matters more than it sounds: the driver keeps a small fixed table of open handles, and a leaked one is a support call three weeks later.
C#, VB.NET and F# share one assembly
There is no separate VB binding. KeyNub.LicenseDongle is a .NET assembly, so Visual Basic and F# consume exactly the same API. We ship a VB.NET sample anyway, because the call style differs enough to be worth showing — Using blocks, no var, and Option Strict On, which is what you want for interop.
Do not gate on a boolean
An if (licensed) is one IL instruction away from if (true), and .NET assemblies are especially easy to inspect and rewrite — a decompiler will hand someone a readable copy of your check. Obfuscation slows that down; it does not stop it. Make the program need something the dongle produces instead:
// Weak: a branch a patcher removes.
if (dongle.IsGenuine) EnableFeature();
// Strong: the values only exist when the dongle does.
byte[] coefficients = dongle.AppDecrypt(EncryptedBlobFromInstaller);Code language: C# (cs)
Because the decrypted data is an input rather than a permission, removing the check does not unlock the feature — it removes the feature’s data.