Skip to main content Skip to footer

The Holy Grail of ASP.NET Licensing

OK, it might not be quite that incredible, but it saves a ton of time when upgrading your bits. If you are like me, and use custom controls, then I am sure you have had a run-in or two with a license.licx file.

If you aren't familiar with license.licx file then I will fill you in. Visual Studio uses this to compile App_Licenses.dll that is used for runtime licensing in applications. Anytime you drop a licensed control onto a form or go into design-view this file is updated with a line item reflecting the controls assembly/version.

Sounds simple enough right? Wrong, in many cases the file becomes outdated, locked (source control), or poorly formatted. Any of these things can case the following error:

Could not transform licenses file 'licenses.licx' into a binary resource.

Even worse, it might actually build flawlessly, but then not work in production due to the controls not recognizing themselves as being licensed correctly!

So here is the holy grail...

  1. Create a web form called LicenseControls.aspx
  2. Add a single instance of every custom control you use in your web app
  3. Delete the licenses.licx file (from the root directory) and App_Licenses.dll (from the Bin)

  4. Go into design view

  5. Ensure that a new licenses.licx file was generated

  6. Optional: Right click on licenses.licx and select "Build Runtime Licenses" just to make sure it builds
  1. Relax

This is a simple trick, but can save you a ton of time when upgrading your licensed control dll's.When you want to upgrade bits, simply drop them in your bin folder, delete the licx file and open this page up in design view. It is really that easy. By doing this you are always creating clean license.licx files with only data for the current versions of your licensed controls. No more nag screens or build errors to prevent you from deploying your shiny new website built with custom controls.

Normally, you would need to find every place in your project that references each different control. Then you would need to open all of those up in design view. Each time you did this it would simply a add new line item to license.licx and leave the old version reference still in the file. Imagine if you got held up in a release cycle on something like this.

Note: If you use source control, you should exclude license.licx from your project as well as App_Licenses.dll in the bin directory.

Here is the LicenseControls.aspx page I use in my projects with references to all of the Studio for ASP.NET controls in 2009 v3: LicenseControls.zip

MESCIUS inc.

comments powered by Disqus