In this blog entry, I would like to explain the required steps to force Visual Studio to compile a specific license into a .NET application. This article should help you, if you get the following error message in Visual Studio:

The following control could not be licensed: TXTextControl.TextControl

That means that Visual Studio could not find an appropriate license to validate the control. Generally, the license will be automatically included into the application and typically do not have to worry about licensing at all.

However, should you wish to do one of the following, it is necessary to take a closer look at licensing:

  • Create TextControl dynamically
  • Encapsulate TextControl in a user control
  • Update an existing project with a newer version of TX Text Control

Creating TextControl Dynamically

Two significant steps are necessary in order to add the license of TX Text Control into an application. These steps must be performed when creating a TextControl instance dynamically:

  1. The project must include a reference to the 'TX Text Control .NET for Windows Forms Component'. To include the reference, select Add Reference... from the Project main menu in Visual Studio. Browse for 'TX Text Control .NET for Windows Forms Component', select it and confirm by clicking OK.
  2. A 'licenses.licx' file must exist in the 'Properties' folder (C#) or the 'My Project' folder (VB.NET). To build such a file, create a new text file in this folder and name it 'licenses.licx'. Open the file and add the following string:
    TXTextControl.TextControl, TXTextControl, Version=13.0.500.500, Culture=neutral, PublicKeyToken=6b83fe9a75cfb638

The 'licenses.licx' file is not a TX Text Control specific file, but a Visual Studio file that is used by 'lc.exe' (which is part of the .NET SDK) to compile the licenses into the assembly. These above steps are done automatically, if you drag and drop a TextControl from the toolbox onto a form.

Encapsulating TextControl in a User Control

Licensing

If you wrap TextControl in a user control assembly, the license information must be in the calling application (exe). It is not sufficient that the user control contains a reference to 'TX Text Control .NET for Windows Forms Component'. Licenses can be only compiled into executable files. The following diagram shows the dependencies:

Updating an Existing Project

Projects will be updated automatically, if only one version of TX Text Control is installed. If you have several versions of TX Text Control installed, perform the following steps:

  1. Load your Visual Studio .NET project.
  2. Open the Add Reference... dialog box in the Project... menu.
  3. Delete the reference to the current TX Text Control version.
  4. Add a reference to the new version and close the dialog box.
  5. Open the licenses.licx file of your project and change the version number of the referenced TX Text Control version to the version number of the newer TX Text Control version.
  6. Close the Visual Studio .NET development environment.
  7. Reopen the Visual Studio .NET development environment.
  8. Rebuild your project using the Rebuild Solution menu item.