Differentiate application editions using "Product Edition" feature
Sample written in C#
Sample written in Visual Basic .NET

It is very common situation when application has some editions available. For example, application comes in 3 editions: Express edition, Standard edition and Professional edition. Your customer is able to download the application and try it out. When he buys it (Express, Standard or Professional) you send him a license key such that it will activate only the required features, according to what he bought.

This schema can be implemented very easy with small additional programming from your side. The Manco .Net Licensing System allows including of the product edition into Unlock Key. So you can include characters that indicates edition of your application to the Unlock Key you will provide to your customer. The key info is encrypted so customer will not have a clue where and how application edition is stored. Our protection library accepts ‘Unlock Key’, validates it and if it is valid return customer specific information (user data and product edition) to you. Your code checks this data and enable or disable some functionality.

To implement this schema you have to include additional rule to the license type: ‘Product edition’. This rule allows enter product edition that then will be encrypted to the Unlock Key. We will differentiate application editions in the code by its code:

To implement this schema you have to include additional rule to the license type: ‘Product edition’. This rule allows enter product edition that then will be encrypted to the Unlock Key. We will differentiate application editions in the code by its code:

  1. EE – Express edition.
  2. SE – Standard Edition.
  3. PE – Professional Edition.

First of all you will need Unlock Key format that allows storing product edition in it. Change format of the Unlock Key on the Version view so it allows storing of the product edition. It could looks like the following:

License Manager - Unlock Key format with Product Edition

The {E2} format specification indicates that 2 characters from the product edition entered in the sale’s view will be stored in the Unlock Key in encrypted form. We suppose that application edition code will be stored in the Unlock Key.

Then you have to create following License Type:

License Manager - Unlock Key with Product Edition license type

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.

Product edition – allows you enter product edition that will be stored in the Unlock Key.

It is easier to select product edition from the list than enter its code. Now configure “Product edition” rule to allow using of the combo box with predefined values instead of simple text box. Put following to the “Default value” column for this rule:

set_control:System.Windows.Forms.ComboBox:EE|SE|PE

It will force License Manager to show drop down with EE,SE and PE values for "Product edition" rule:

License Manager - Select Product Edition from combo box

Next step – create license file for your application. This process is absolutely similar to the one is described in our documentation in the Quick Start using “Unlock Key” licensing schema article, so we just show screenshot for this sale record.

License Manager - Evaluation Sale with Product Edition

Pay attention, that “Product edition” and “Unlock Key” are empty.

Now you have to prepare your application code to be able working with this licensing schema. The main difference with code from Quick Start using "Unlock Key" licensing schema article will be extraction of the product edition from the Unlock Key. Additional code in your application could looks like the following:

[C#]
if (license.IsValid)
{
	// Get product edition
	if (license.IsEvaluation)
	{
		lblProductEdition.Text = "Evaluation";
	}
	else
	{
		switch (license.ProductEdition)
		{
			case "EE":
				lblProductEdition.Text = "Express Edition";
				break;

			case "SE":
				lblProductEdition.Text = "Standard Edition";
				break;

			case "PE":
				lblProductEdition.Text = "Professional Edition";
				break;
		}
	}
	// All other application inicialization goes here

}
else
{
	// Not valid license.
	MessageBox.Show("Your license isn't valid.",
		  "Sample Application",
		  MessageBoxButtons.OK,
		  MessageBoxIcon.Stop);
	Application.Exit();
}
    
[Visual Basic]
If license.IsValid Then
	' Get product edition
	If license.IsEvaluation Then
		lblProductEdition.Text = "Evaluation"
	Else
		Select Case license.ProductEdition
			Case "EE"
				lblProductEdition.Text = "Express Edition"

			Case "SE"
				lblProductEdition.Text = "Standard Edition"

			Case "PE"
				lblProductEdition.Text = "Professional Edition"
		End Select
	End If

	' All other application inicialization goes here

Else
	' Not valid license.
	MessageBox.Show("Your license isn't valid.", _
	   "Sample Application", _
	   MessageBoxButtons.OK, _
	   MessageBoxIcon.Stop)
	Application.Exit()
End If
    

As next step you can limit some functionality in the different editions. The Manco.Licensing protection library provides you with custom “AllowedInEdtion” attribute. It can be applied to any method in your application to allow its execution only in specified editions. It must be used in conjunction with the license.IsMethodAllowed property:

[C#]
[AllowedInEdtion("SE,PE")]	
private void StandardMethod()
{
	if(license.IsMethodAllowed)
	{
		// Perform operations
		// ...
	}
}
    
[Visual Basic]
<AllowedInEdtion("SE,PE")> Private Sub StandardMethod()
	If license.IsMethodAllowed Then
		' Perform operations
		' ...
	End If
End Sub
    

The license.IsMethodAllowed property automatically checks if the product edition stored in the Unlock Key corresponds to one is listed in the “AllowedInEdition” attribute, and return true if method is allowed in the current edition.

Now you can create Unlock Keys for Express, Standard or Professional editions.

Sale of the Express Edition:

License Manager - Sale of the Express Edition

Sale of the Standard Edition:

License Manager - Sale of the Express Edition

Sale of the Professional Edition:

License Manager - Sale of the Express Edition

Pay attention, when you create Unlock Key in License Manager you have to enter "Product edition" first in order this data will be stored in the Unlock Key.

To implement this licensing schema you need Standard or Professional Edition of our product.


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