Quick Start using “Unlock Key” licensing schema
Sample written in C#
Sample written in Visual Basic .NET

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 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.

License Dialog

Click “OK” button to close it. The main application window appears:

License Manager

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:

  1. Open your .NET project in the Visual Studio.
  2. Double-click “Properties” node under your project name in the Solution Explorer.
  3. Click “Signing” tab.
  4. Check “Sign the assembly” checkbox.
  5. From the “Choose a strong name key file” drop down select “<New…>”.
  6. Enter parameters of the key file and click “OK” button.
Sign assembly

Now you should enter necessary assembly information in the Visual Studio:

  1. Open your .NET project in the Visual Studio.
  2. Double-click “Properties” node under your project name in the Solution Explorer.
  3. Click “Application” tab.
  4. Press the “Assembly Information” button. The “Assembly Information” dialog will appear:
    Visual Studio - Assembly Information
  5. Fill in following fields: “Company”, “Product”, “Assembly version” and “File version”. These fields are mandatory.
  6. Click “OK” button.
  7. Rebuild your project.

Click License Manager - Import Product 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:

License Manager - Product

Click version tile to open version properties. Fill in the “License file name” field. 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:

License Manager - Version

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:

  1. Switch to the “License types” tab in the version definition. License Manager - Version - License types

  2. Expand “Add license type” dropdown. You will see list of the predefined license types: License Manager - Version - Predefined license types

  3. Select “Unlock Key” and click License Manager - Import Product button. You will see “Edit license type” window with predefined rules selected: License Manager - Version - Edit license type

  4. Click “OK” button. New license type will be created.

Included license rules operate as following:

Expiration Days – 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 License Manager - Save changes toolbar button.

Stay on the “License types” tab and click the “Mange sales” button:

License Manager - Version - Manage Sales

The "Mange sales" window appears

License Manager - Version - Manage Sales Window

Click License Manager - New Sale toolbar button. Now you should see a window with 2 tabs. The "Customer" tab contains many fields for customer information, and the "Sale" tab contains the sections for license parameters:

License Manager - New sale window

First, you should put for customer name “License File” so that you can recognize it from your other sales later on:

License Manager - New sale - license file customer

Next, go to the “Sale” tab and take a look into the “License Parameters” section. Check the “Write Key to File”, and choose how many days of evaluation use you want your customers to have before the evaluation expires:

License Manager - New sale - license file

Pay attention, “Unlock Key” field in this record MUST be empty. Click OK to add new sale:

License Manager - Manage Sales Window - license file

Close the “Manage sales” window.

The next step is to integrate license protection into your .NET application.

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:

Visual Studio - Target Framework
  1. If target framework is “.NET Framework 4.0” then you should use DLL which is located in the InstallationPath/DLL/NET40/Full/Manco.Licensing.dll.
  2. If target framework is “.NET Framework 4.0 Client Profile” then you should use DLL which is located in the InstallationPath/DLL/NET40/ClientProfile/Manco.Licensing.dll.
  3. If target framework is “.NET Framework 4.5” then you should use DLL which is located in the InstallationPath/DLL/NET45/Full/Manco.Licensing.dll.
  4. If you are developing .NET Windows Store application then you should use DLL which is located in the InstallationPath/DLL/WinStore/Manco.Licensing.dll

The InstallationPath depends on your OS:

  1. For 32-bits OS it is “C:\Program Files\Manco Software\Manco .NET Licensing System”.
  2. For 64-bits OS it is “C:\Program Files (x86)\Manco Software\Manco .NET Licensing System”.

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 Manco.Licensing namespaces are imported to your class:

[C#] [Visual Basic]

Manco .NET Licensing System requires that one of the classes in your application implements Manco.Licensing.ILicenseKeyProvider interface. In this example we include implementation of this interface into the MainForm 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.

  1. Switch to the “Project” tab in the version view: Visual Studio - Version - Project

  2. Select programming language from the “Language” drop-down and click “Generate” button: Visual Studio - Version - Generate ILicenseKeyProvider

  3. The window with implementation of the ILicenseKeyProvider appears. Click “To Clipboard” button: Visual Studio - Version - Generate ILicenseKeyProvider

  4. Go to your project and paste code to the class which implements ILicenseKeyProvider interface (MainForm in our case).

  5. Click “OK” to close window.

The best place to initialize license variable is class constructor (method “New” in VB.NET):

[C#] [Visual Basic]

Next, the program needs to load license file, verify licensed and calling (if necessary) assemblies and check to see the license state. 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”:

Visual Studio - Solution Explorer

In the License Manager go to the “License types” tab and click the “Mange sales” button:

License Manager - Version - Manage Sales

In the “Manage sales” window select “License File” customer you’ve created early. Right click the correspondent sale record in the bottom part of the window and select “Save license file” context menu item:

License Manager - Manage Sales Window - Context menu

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.

Visual Studio - Embedded Resource

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 state 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.

In the License Manager go to the “License types” tab and click the “Mange sales” button:

License Manager - Version - Manage Sales

Click License Manager - New Sale toolbar button. You will see “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 License Manager - Search customer toolbar button to perform search of the client through the database:

License Manager - Real Customer

Switch to the “Sale” tab and click License Manager - Generate unlock key toolbar button to generate Unlock Key.

License Manager - Real Sale

Click OK to add new sale.

If unlock key format contains unique license type ID ({L…}) and/or unique customer ID ({C…}), then License Manager - Generate unlock key will be disabled while license type ID and/or customer ID is not available. You must click License Manager - Search customer on the “Customer” tab to be able to generate Unlock Key.

Now you can copy and paste “Unlock Key” have been generated to the evaluation form and get your application fully functional. You always can open sale record using “Edit sale record” button:

License Manager - Edit sale

Then you can copy Unlock Key to clipboard from the “Edit sale window”. But there is more suitable way to do it. You can reconfigure sales grid view to show license rules and custom values.

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.


Sample written in C#
Sample written in Visual Basic .NET
Manco .NET Licensing System Home Page