Search code examples
.netcontrols.net-2.0sax

ComponentModel.LicenseException on Windows 7 for licensed control


I have a project that works fine under Visual Studio 2008 on Windows XP. I'm setting up a Windows 7 64-bit system with Visual Studio 2008 and I have found that one of my licensed controls fails its license check. On compiles I get this error:

Exception occurred creating type 'Sax.Barcodes.Barcode, Sax.Barcodes, Version=1.2.0.0, Culture=neutral, PublicKeyToken=57b9527db291dbf8' System.ComponentModel.LicenseException: An instance of type 'Sax.Barcodes.Barcode' was being created, and a valid license could not be granted for the type 'Sax.Barcodes.Barcode'. Please, contact the manufacturer of the component for more information. Licenses.licx

I have installed the Sax controls on my system and put in my serial number. It is worth noting that these controls are .Net 1.1 controls and I am switching the project to 2.0. It's also worth noting that I was able to successfully upgrade the project to .Net 2.0 on my XP system and the licensing worked fine. It seems like the Sax Barcode installer didn't set up the licensing right in Win 7 and/or VS 2008.

I tried adding the Barcode control to the toolbox but I get an error saying:

There are no components in 'C:\Program Files (x86)\Sax.net\Barcodes\Deploy\Sax.Barcodes.dll' that can be placed on the toolbox.

Any ideas how to better debug what is happening?

Edit: I have tried to compile with the platform set to x86 as well and I get the same error. I tried under WinXP on the same system that has always been able to build the .Net 1.1 version and it fails with the same error. If I include a license.licx file in the project then I get the error at compile time. If I don't include it then I get the license error at run time.


Solution

  • I deconstructed the DLL's code and found some odd things.

    First, this library has this error hardcoded. So you will never find anyone else with it because its not using the built-in license handling code.

    Second, if your username on that machine is "CHUCKG" or "MARKH", it'll probably let you right on through due to hard coded values.

    Third and here is the answer, you need to have Visual Studio running as Administrator in order for it to find the registry keys/license properly.

    Thanks to @sontek for the refresher.