Manco .NET Licensing System provides many different ways to license.NET products. The most popular way is licensing by secure “Unlock Key”. We’ve selected it to give quick start instructions to you. Many steps are described in this topic are similar for most licensing schemas.
Note: Protection library require that protected project will be signed. Don’t forget to sign your assembly.
Firstly you need understand how the “Unlock Key” licensing schema works. When customer downloads your application from the Internet he or she gets an evaluation version. It will start out in evaluation mode, limited by the number of days the customer can run it. When the customer buys your application, he or she will receive an unlock key, enter it into the application, and get not limited, fully functional application.
Now you need prepare all necessary licensing information and integrate license protection to your application. License Manager is the tool that is used to prepare licensing information. It also helps integrate license protection to your application. Go to the Windows Start menu at the “All Programs->Manco Software->Licensing System” and click License Manager. If you are still running it in evaluation mode, you will have to first close the licensing dialog before you get to the main application window.
Click “OK” button to close it. The main application window appears:
The protection library uses information stored in the license file to check license validity. Firstly it tests whether the license file is used with right product and version. To get this information included to the license file you should now create Product and Version descriptions in the License Manager.
The simplest way to do it is using of the information included into the binary output (EXE or DLL) of the project you’d like to protect. First of all, sign your assembly:
Now you should enter necessary assembly information in the Visual Studio:

Click
toolbar button. Select binary output (EXE or DLL) of your project in the file open dialog. The new product and version description will be created:
Select version node and fill in the “Default File Name”. This field should contain name of the license file that will be used by your system. It can be any valid file name with any extension you’d like, but we suggest you name your license files so you could detect what it is for using file name. You can leave default value in other fields for now:
Now you should create License Type that will allow your application operate as you desire: application will start out in evaluation mode, limited by the number of days the customer can run it. When the customer buys your application, he or she will receive an unlock key, enter it into the application, and get not limited, fully functional application.
This is good known license type which we call “Unlock Key”. To create new license type click expand button on the “Add License Type” toolbar button:
. You will see list of the predefined license types:
Click “Unlock Key”. New license type will be created. In Manco .NET Licensing System the way how protection library operates is set by list of the license rules included to the license type. By default “Unlock Key” license type includes following rules: “Expiration Dates”, “Is Evaluation”, “Unlock Key” and “Write Key to file”.
Included license rules operate as following:
Expiration Dates – set number of days during which your product will work in evaluation mode. This license rule can be used to create evaluation. When someone attempts use licensed product after given number of days it will give “Your license has been expired” exception.
Is Evaluation – indicates, that license is in evaluation mode. Allows you limit some functionality in your product using evaluation status of license.
Unlock Key – including of this validation rule to the base license file allows you using of the “Unlock Key” schema to activate product. It informs protection library that Unlock Key provided by customer should be validated.
Write Key To File – indicates whether the “Unlock Key” should be written to the protected storage after validation. If you don’t use this rule, then customer will be asked for Unlock Key every time when your application starts.
Now you should create evaluation license file. This file will be distributed with your application. It will contain all necessary licensing information, such as the number of evaluation days available, and the Unlock Key needs to be saved to the protected storage. To do this, you need to add a sale under this license type. We call it “evaluation sale”.
Before creation of the “evaluation sale” you have to save all changes made in the License Manager. To do it click
toolbar button.
Click
toolbar button. Now you should see a window with many fields for customer information, and a section for license parameters at the bottom. First, you should put for customer name “License File” so that you can recognize it from your other sales later on. Next, go down to the License Parameters section. Check Write Key to File, and choose how many days of evaluation use you want your customers to have before the evaluation expires.
Pay attention, “Unlock Key” field in this record MUST be empty. Click OK to add new sale.
Save all changes made in the License Manager. To do it click
toolbar button. All records have been created in the License Manager will be saved in the database. The next step is to integrate license protection into your .NET application.
Pay attention, “Unlock Key” field in this record MUST be empty. Click OK to add new sale.
Firstly you should add reference to the Manco.Licensing DLL into your project. Location of this DLL depends on the target framework which is set for your project:
The InstallationPath depends on your OS:
For Windows desktop application (either Windows Forms or Windows Presentation Foundation) the best place to insert base licensing code is main application window class.
Check that System.ComponentModel and Manco.Licensing namespaces are imported to your class:
[C#] [Visual Basic]Next, put this line of code directly above your class definition:
[C#] [Visual Basic]Manco .NET Licensing System requires that protected class implements Manco.Licensing.ILicenseKeyProvider interface. You must include this interface to the list of the interfaces are implemented by your class. To perform operations on the license (validate it or check expiry status) you should include license management objects to your class. Finally your class definition code could look like following:
[C#] [Visual Basic]Now you must include implementation of the ILicenseKeyProvider interface to your code. License Manager can prepare this code for you. Right click on the version number in the tree view (6.2.0.0)
Select “Generate ILicenseKeyProvider Code” and choose programming language that you are using, and you will see a dialog pop up with code:
Click “To Clipboard” button. Go to your project and paste code to the protected class. You will need to make one change, however. In the property BypassExpirationCheck, instead of returning “false”, return “true”. This will make it so that Manco.Licensing DLL doesn’t throw an exception if the license is expired, and so that you can handle it yourselves.
[C#] [Visual Basic]The best place to initialize license variable is class constructor (method “New” in VB.NET). You also need pass information about licensed (and calling, if necessary) assembly to the license object:
[C#] [Visual Basic]Next, the program needs to check to see the status of the license. If it is evaluation, or not valid, a dialog needs to be shown that allows the user to input an Unlock Key. We leave implementation of the evaluation window on your own, so you can put anything you’d like to it. The simple form can contain notification text and text field Unlock Key. You should provide a way to get entered key from the form and put it to the “UnlockKey” property of the license object. It looks like the best place for this code is “OnLoad” event handler:
[C#] [Visual Basic]Now you should add evaluation license file to your project. “Unlock Key” licensing scheme requires only 1 license file that will be redistributed with application. The best practice is to include this license file to your project as embedded resource.
Create new folder in your project and call it “License”:
In the License Manager select license type node, switch to the “Sales” tab and select “License File” sale you’ve created early.
Click
toolbar button in the sale toolbar. In the “Save File” dialog select location for license file so it will be in “License” folder inside your project. Save file.
In the Visual Studio solution explorer right click the “License” folder and select “Add->Existing Item”. In the “Add Existing Item” dialog select license file to add it into your project. In the solution explorer select file you’ve added and go to the “Properties” window. Set “Build Action” to the “Embedded Resource” for this file.
Now you application is ready to run. First time you start it you will see evaluation window with field to enter “Unlock Key”. If you simple close this window your application will continue execution in the evaluation mode. You can check this mode using “IsEvaluation” property of the license object. You can enable or disable some functionality or GUI controls based on this status. To get your application fully functional you have to create “Unlock Key” for it.
Click
toolbar button. You will “Add new sale” window. Enter necessary customer information. Actually it is enough enter customer name and e-Mail, but we would recommend at least First and Last name too. Click
toolbar button to perform search of the client through the database. Click
toolbar button to generate Unlock Key.
Click OK to add new sale. Save all changes made in the License Manager. To do it click
toolbar button. All records have been created in the License Manager will be saved in the database.
If unlock key format contains unique license type ID ({L…}) and/or unique customer ID ({C…}), then
will be disabled while license type ID and/or customer ID is not available. If you add new sale for customer, then you have to click OK to add new sale without generation of the Unlock Key. Then save changes made and click
in the sale information toolbar.
Now you can copy and paste “Unlock Key” have been generated to the evaluation form and get your application fully functional. Protection library will store valid Unlock Key in the protected storage, so your customers will not be requested for it next time they start your application.