Once you’ve installed Manco.Licensing System you can start protect you products. Manco License Generator provides you with all functionality you need for complete license and customer management. Start this application from the “Start” menu. If you’ve not bought license for the Manco.Licensing System yet, then you will see licensing dialog, shown below:
Click “OK” to start your evaluation. If you’ve purchased license and put license file to the appropriate place (“License” folder near the license generator’s executable) you wouldn’t see this message. The main window of the License Generator:
At the first you need to create base information about product you’d like to protect. The most easy and quick method to create all Product->Version->List of License Types chain is using of the “New Product Wizard”. To run it you should use main menu “File->New->Run Product Wizard” command. You will see the start page of the wizard:
Enter necessary information about product and click “Next” button. Second page allows you enter information about product version. Using the “Generate Crypto Parameters and Version Key” checkbox you can select whether the main crypto keys should be generated by wizard, or you’d like to do it later. Most common scenario is when crypto keys are generated by wizard, so this checkbox is initially checked.
Enter necessary information about product’s version and click “Next” button. The third page allows you select some license types from the list of predefined ones to use with your product.
Select any number of types in the “Predefined Types” list by checking checkboxes and click “-->” button. Check “Main use” comment at the end of the license type name to be sure that this particular type fit for your requirements. To remove unneeded types from the “In Use Types” list, you should select them in this list and click “<--” button. Click “Next” button to see summary about information you’ve entered.
Click “Finish” button to insert information to the product tree. You should click “Save” button in the toolbar to store new product to the database. If you’ve leave “Generate Crypto Parameters and Version Key” checkbox on the Version page checked, then you currently have all necessary information to license your product. You can now generate ILicenseKeyProvider source code for your product, secure your application or control with Manco.Licensing assembly and start entering information about purchases.
In case if you’ve unchecked “Generate Crypto Parameters and Version Key” checkbox you should generate or copy RSA key and generate version key before you can go forward. To do it, right click on the Version node (something like 1.5.0.0). You will see the Version context menu:
Select “Generate RSA” to generate Crypto Parameters and the right click again on the same node and select “Create Version Key”.
Now we should modify your project. Add following references to the project that will be protected:
Now you should insert base licensing code into your product. It doesn’t matter is it an application, component or just a class. Insert following line of code
[C#]
[LicenseProviderAttribute(typeof(Manco.Licensing.LicenseProvider))]
[Visual Basic]
<LicenseProvider(GetType(Manco.Licensing.LicenseProvider))> _
right before the class definition statement. Manco.Licensing needs that protected class implements Manco.Licensing.ILicenseKeyProvider interface, so you should include this interface to the list of the interfaces are implemented by your class. Finally your class definition code could look like following:
[C#]
[LicenseProviderAttribute(typeof(Manco.Licensing.LicenseProvider))]
public partial class MainForm : Form, ILicenseKeyProvider
{
…
}
[C#] [Visual Basic] <LicenseProvider(GetType(Manco.Licensing.LicenseProvider))> _ Public Class MainForm Implements ILicenseKeyProvider … End Class
You can implement properties of the ILicenseKeyProvider by yourself or use functionality provided by Manco License Generator. Right click on the Version node or Version View and select Generate ILicenseKeyProvider Code ->In C# or In VB.NET. You will see a dialog that contains source code in the selected language.
Select text in the textbox, copy it to the clipboard and paste to your licensed code. The next step is insertion of the licensing code into your application. At the first you should create an object of the Manco.Licensing.License type. Pay your attention that ILicenseKeyProvider implementation uses prospective license variable for some purposes, so it’s a good idea to make license variable private member of the protected class. It also allows you using of this variable to limit evaluation version of the product with some functionality or validate license in the different places of your code. Put following code somewhere in the class code:
[C#] private Manco.Licensing.License license; [Visual Basic] Private license As Manco.Licensing.License
Now you need to instantiate this variable. The good place is a constructor of the licensed class. Put somewhere in the constructor following code:
[C#] license = (Manco.Licensing.License)LicenseManager.Validate(typeof(MainForm), this); license.CallingAssembly = System.Reflection.Assembly.GetCallingAssembly(); license.LicensedAssembly = System.Reflection.Assembly.GetExecutingAssembly(); [Visual Basic] license = LicenseManager.Validate(GetType(MainForm), Me) license.CallingAssembly = System.Reflection.Assembly.GetCallingAssembly() license.LicensedAssembly = System.Reflection.Assembly.GetExecutingAssembly()
Now you can use license object to validate license you provided with your product. It could be unlock key or license file, in any case validation should be done by checking IsValid property of the license object. You can use it anywhere in your code (in the class constructor, for example). Currently your source code looks like the following:
[C#] [LicenseProviderAttribute(typeof(Manco.Licensing.LicenseProvider))] public partial class MainForm : Form, ILicenseKeyProvider { private Manco.Licensing.License license; public MainForm() { InitializeComponent(); // Instantiate license object and assign assemblies will be validated license = (Manco.Licensing.License)LicenseManager.Validate(typeof(MainForm), this); license.CallingAssembly = System.Reflection.Assembly.GetCallingAssembly(); license.LicensedAssembly = System.Reflection.Assembly.GetExecutingAssembly(); } private void MainForm_Load(object sender, EventArgs e) { if (license.IsValid) { // Initialize application } else { MessageBox.Show("License Not Valid", "Sample Application", MessageBoxButtons.OK, MessageBoxIcon.Stop); Application.Exit(); } } #region ILicenseKeyProvider Members ... #endregion } [Visual Basic] <LicenseProvider(GetType(Manco.Licensing.LicenseProvider))> _ Public Class MainForm Implements ILicenseKeyProvider Private license As Manco.Licensing.License Sub New() ' This call is required by the Windows Form Designer. InitializeComponent() ' Instantiate license object and assign assemblies will be validated license = LicenseManager.Validate(GetType(MainForm), Me) license.CallingAssembly = System.Reflection.Assembly.GetCallingAssembly() license.LicensedAssembly = System.Reflection.Assembly.GetExecutingAssembly() End Sub Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If license.IsValid Then ' Initialize application Else MessageBox.Show("License Not Valid", _ "Sample Application", _ MessageBoxButtons.OK, _ MessageBoxIcon.Stop) Application.Exit() End If End Sub #Region "ILicenseKeyProvider Members" … #End Region End Class
Currently you can build your product and start issue license files. To prepare your licensed product to accept "Unlock Key" see "How to prepare product to accept "Unlock Key".