Setting up a software licensing system for .NET applications can easily be done in two ways. In the past, one common way was to code a simple license key generator and a subset of license keys that the code validates. However, given the many benefits of such a solution, most companies have today chosen the second way, which is to outsource software licensing to a Licensing as a Service provider. This blog will dig deeper into these two options to help you set up software licensing for a .NET project.
Now, why are license key generators no longer the preferred chose for licensing .NET code? It has a lot to do with both scalability and flexibility. A simple self-coded key generator only performs partial license key verification, making the process of checking the license keys less secure. Additionally, the subset of license keys and the structure used to generate them will start to break after some time. These reasons makes self-coded licensing systems easy to bypass and troublesome to maintain. You can read more about this option in this blog post.
The preferred method of licensing .NET applications today is by outsourcing licensing to experts. A Licensing as a Service (LaaS) provider such as Devolens will provide you with advanced licensing features that you can access from an easy-to-use dashboard from day 1. We have comprehensive implementation guides in .NET, along with other languages. Implementing our cloud-based licensing solution is effortless!
The first step to implementing our solution is to sign up to our dashboard. We have a free plan to use during the implementation phase, so there is no rush! Our .NET SDK can be downloaded for free, and you only have to paste a short code snippet into your application's code. Our full documentation page is available for reference, but to verify a license key, a similar code to the one below can be used.
' The code below is based on https://help.cryptolens.io/examples/key-verification.
Dim token = "{access token with permission to access the activate method}"
Dim RSAPubKey = "{Your RSA Public key}"
Dim keyStr = TextBox1.Text.Replace(" ", "")
Dim result = Key.Activate(token:=token, parameters:=New ActivateModel() With {
.Key = keyStr,
.ProductId = 3349,
.Sign = True,
.MachineCode = Helpers.GetMachineCode()
})
If result Is Nothing OrElse result.Result = ResultType.[Error] OrElse
Not result.LicenseKey.HasValidSignature(RSAPubKey).IsValid Then
' an error occurred or the key is invalid or it cannot be activated
' (eg. the limit of activated devices was achieved)
MsgBox("Unable to access the license server or the key is wrong.")
Else
' everything went fine if we are here!
Dim license = result.LicenseKey
Form1.Button1.Enabled = license.HasFeature(1).IsValid() ' either we have feature1 or not.
Form1.Button2.Enabled = license.HasFeature(2).IsValid() ' either we have feature2 or not.
Form1.Button4.Enabled = license.HasFeature(3).IsValid() ' either we have feature3 or not.
Form1.Text = "Digital Tools"
If license.HasFeature(4).HasNotExpired().IsValid() Then
' feature 1 is a time limited, so we check that it has not expired.
Form1.Text = "Digital Tools - " + license.DaysLeft().ToString() + " day(s) left"
ElseIf license.HasNotFeature(4).IsValid() Then
Else
MsgBox("Your license has expired and cannot be used.")
nolicense()
End If
license.SaveToFile()
End If
More examples can be found here.
Join hundreds of industry-leading software companies who have already chosen us as their software licensing system.