In Service Pack 2, we have made a number of significant changes and improvements in a variety of areas, including the licensing mechanism.
Say Goodbye to licenses.licx
For years, Microsoft supported a licensing scheme for third-party components like TX Text Control. This mechanism used a license file named licenses.licx to compile licensed components into the assembly using the license compiler (lc.exe) that is part of the .NET Framework. It takes a text file containing licensing information and creates a binary file to embed as a resource in a common language executable.
This license compiler is no longer available in .NET 6 and later versions. To support .NET, we used this as an opportunity to redesign the licensing mechanism and change other related parts. This change applies only to .NET-based applications. Applications that are based on the .NET Framework will continue to use the licenses.licx approach because it is fully supported by Microsoft.
New License File
The NuGet packages have been updated to be compatible with .NET 6 and better. The libraries in the package are now .NET 6 target libraries. When TX Text Control is added to a project using one of the NuGet packages, a new license file is added:
The name of the license file varies depending on the product added:
- TXTextControl.TextControl.ASP.SDK
txtextcontrol.server.license - TXTextControl.TextControl.WinForms.SDK
txtextcontrol.winforms.license - TXTextControl.TextControl.WPF.SDK
txtextcontrol.wpf.license
Since this file is an embedded resource, the license will be automatically embedded into the assembly during compilation.
Important
The license file is generated and contains private, encrypted serial number information unique to each installation. The license file may not be passed on to other users, nor may it be distributed in any form.
Entry Assembly
As of 32.0 SP2, TX Text Control can be used in class libraries and called from other unlicensed assemblies. In previous versions of TX Text Control, the license must have been compiled into the main calling assembly. The new static property EntryAssembly has been introduced to allow you to specify where TX Text Control should look for the license.
The following code shows how a Class Library that contains the TX Text Control license can be called from other assemblies without a reference to TX Text Control and without a license.
namespace MyClassLibrary | |
{ | |
public class Class1 | |
{ | |
public Class1() | |
{ | |
TXTextControl.ServerTextControl.EntryAssembly = typeof(Class1).Assembly; | |
} | |
} | |
} |
The assembly setting defines where TX Text Control looks for the license. In the above example, the class library itself contains the license, and TX Text Control will look for the license in the class library.
This allows another assembly to call members that use TX Text Control without a reference or license to TX Text Control. The following screenshot shows a console application with a project reference to the class library.
Typical Use Cases
There are two typical use cases for the new licensing mechanism:
- TX Text Control is used in a class library that is called from other assemblies.
-
Class libraries that use TX Text Control should be tested using test frameworks such as NUnit or MSTest.
Learn More
Unit testing is a common practice in which code is tested in isolation. This article shows how to use TX Text Control .NET 32.0 in such environments, and in particular how to handle licensing.
Unit Testing with NUnit and MSTest and TX Text Control .NET 32.0