There is no separate VB binding to learn: KeyNub.LicenseDongle is a .NET assembly, so VB.NET consumes exactly the same package as C# and F#. What differs is the call style.
dotnet add package KeyNub.LicenseDongleCode language: Bash (bash)
Reading a License
Option Strict On
Imports KeyNub.LicenseDongle
Using ctx As LicenseDongleContext = LicenseDongleContext.Create()
Dim devices = ctx.Enumerate()
If devices.Count = 0 Then
Console.WriteLine("Please plug in your KeyNub license dongle.")
Return 0
End If
Using dongle As Dongle = ctx.Open() ' first dongle found
dongle.VerifyGenuine() ' throws unless genuine
Using session As Session = dongle.OpenSession()
Dim licence As Byte() = session.ReadRecord("license")
End Using
End Using
End UsingCode language: VB.NET (vbnet)
Turn Option Strict On
Some tooling still creates VB projects with Option Strict Off. For code that talks to hardware through a native library, that is exactly the wrong default: a silent narrowing conversion of a byte array, a handle or a length is the class of bug that shows up as corruption at a customer site rather than as a compile error on your machine. The sample sets <OptionStrict>On</OptionStrict> in the project file, and we would recommend the same in yours.
The nested Using blocks are doing real work: each one closes its resource on every exit path, including when an exception unwinds. The dongle driver keeps a small fixed table of open handles, and a leaked one becomes a support call weeks later.
Do Not Gate on a Boolean
A .NET assembly decompiles into readable source, and an If licensed is one IL instruction away from If True. Obfuscation raises the effort; it does not remove the branch. Make the program need something only the dongle can produce:
' Weak -- a branch a patcher removes.
If isLicensed Then EnableFeature()
' Strong -- the values only exist when the dongle does.
Dim coefficients As Byte() = session.AppDecrypt(EncryptedBlobFromInstaller)Code language: VB.NET (vbnet)
Full VB.NET sample on GitHub · the same thing in C# · in F#
Shipping the Native Library with a VB.NET Application
The KeyNub.LicenseDongle NuGet package carries the native library for every platform under runtimes/<rid>/native/: win-x86, win-x64, win-arm64, linux-x64, linux-arm64 and osx. On .NET 8 and later the host picks the right one at run time, and a framework-dependent or self-contained dotnet publish for a runtime identifier takes exactly that one. On .NET Framework, through netstandard2.0, the package’s MSBuild targets copy the library next to your executable and the binding pre-loads it.
Nothing else is deployed: no driver, no service, no registry entry. Single-file publishing and trimming work, because the native library is a plain file beside the executable rather than something the linker sees. On Linux, install the udev rule from NATIVES.md once, so that ordinary users may open the device.
Questions VB.NET Developers Ask
Which .NET Versions Does the Binding Support?
The assembly targets net8.0 and netstandard2.0, so it runs on .NET 8 and later and on .NET Framework 4.6.1 and later, on Windows, Linux and macOS.
Does a VB.NET Application Need Administrator Rights to Talk to the Dongle?
No, and no driver either: the dongle is a USB HID device that the operating systems handle with their built-in class drivers. On Linux, install the shipped udev rule once so that ordinary users may open it; without the rule the SDK reports access denied and names the cause in its error detail.
Does a VB.NET License Check Need an Internet Connection?
No. Verification is a local exchange between your program and the dongle over USB: the SDK checks the dongle’s certificate chain to KeyNub’s root and runs a live challenge-response. There is no activation server and no account, so the check works on air-gapped machines.
Who Can Read the License Records on a Dongle?
Anyone holding the dongle: a program opens a session and reads records, and can decrypt data sealed for that dongle. Writing records, erasing them and incrementing counters need your write key. What the dongle guarantees is that none of it is available without the dongle present.
Can a License Written from VB.NET Be Read by a Program in Another Language?
Yes. Every binding drives the same core library and the same dongle, and records and sealed data are language-neutral bytes. Your issuing tool can be written in one language and your product in another.
All supported languages · All industries · Buy a KeyNub · Ask us something