Finding and fixing errors in the licenses.licx file is one of our most frequent support requests, and with the attached sample, you can now generate your .licx file automatically.
About .Net Framework licensing and licx files
The Microsoft .NET Framework has a built-in, extensible licensing architecture that supports design-time and run-time licensing for managed components, including Windows Forms controls, ASP.NET server controls and WPF controls (Applications Licensing using the .NET Framework).
Most of the functionality you need as a customer of third-party components is already embedded into Visual Studio. When you drop a third-party control from the toolbox onto the design surface, VS creates a text file with .licx extension, adds it to the project as an embedded resource, and fills it with information about the controls. Then, when you build the project on a machine with an installed license, the License Compiler reads text files that contain the licensing information and produces a binary output that's embedded into runtime, executable as a resource. When you run this application on any machine, components don't need the license installed on computer; they only check the license embedded into application manifest. That's it in theory.
Of course, things go wrong. You might edit your code manually, and then the IDE couldn't generate a valid .licx file for your app. Or you could upgrade binaries to a newer version. Or someone from your team could override this file content, etc. If there's something wrong with .licx file in your project, you might get build errors, or even worse - your customers might get nag screens or runtime exceptions even if you have valid license.
The popularity of our Licensing Problems - The licenses.licx File and You blog post shows how frequently this problem crops up. The post describes what should be included in the WinForms licenses.licx file, and how you can fix it manually. It's all the same for our WPF controls and for WinForms and WPF controls of other vendors. You can do it manually, but on big projects it's not always easy to find what is missing.
The LicxGenerator tool
Fortunately, this task can be automated, and many thanks to our customer Dom Sinclair for inspiration. The attached LicxGenerator tool creates a license.licx file with license information entries for all controls found under a specified path. If you run it, it asks you to browse for the binaries folder and then put the generated file under the same path. If you need more control, you can run it with command line options. You can also run it with other automated tasks.
LicxGenerator [-r] [-p prefix] [-s] [sourcePath] [outputPath]
- -r : For recursive search in subfolders;
- -p : Only search in files which names start from the specified prefix;
- -s : Silent mode.
If both sourcePath and -s parameter are not set, the utility will show the folder selection dialog. If the outputPath is not set, it will be the same as sourcePath value.
To generate licenses.licx file for your project:
- Build your project first, so that output folder contains all binaries;
- Run LicxGenerator with path to the project output folder;
- Take generated license.licx file and add it to the project.
This free tool will save you a lot of time on digging into licensing issues. We also attached full source code in case if you want to play with it. Please feel free to share your feedback and suggestions.
Extensible .NET UI controls for mobile, web, and desktop Download the latest version of ComponentOne Studio Enterprise
Extensible .NET UI controls for mobile, web, and desktop
Download the latest version of ComponentOne Studio EnterpriseDownload Now!
4 May 2016 - excluded abstract classes.
Download LicxGenerator application >> (8.67 KB exe)
Download LicxGenerator source code >> (4.49 KB zip)