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.
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.
You've probably already figured it out or done something else, but I've run into the same problem in the past and finally figured it out, gone a period of time and encountered the same thing in a different project and couldn't remember what it was. Therefore I'm posting this in case someone else runs into the same thing.
The text in the Licenses.licx needs to be modified for the newer versions of .Net. Instead of "Sax.Barcodes.Barcode"
, try using "Sax.Barcodes.Barcode,Sax.Barcodes"
(minus the quotes). Of course, make sure you installed the package with the serial number, include the DLL and Licenses.licx files in your project. Hope it saves someone else a headache!
Do you know if your project is running as 32 bit or 64 bit? In VS, if you go to the project properties for your .exe project (assuming this is a Windows application), on the build tab, if "platform target" is set to "any CPU", try changing it to "x86" and recompiling. (I'm looking at VS2010, the dialog might look slightly different in VS2008.)
Process Monitor from Sysinternals (http://technet.microsoft.com/en-us/sysinternals/bb896645) might help you work out where the component is looking for the licence. It will monitor all file system and registry access, and you might be able to see where the component is looking for its licence file.
精彩评论