View previous topic :: View next topic |
Author |
Message |
greek
Joined: 07 Feb 2007 Posts: 7
|
Posted: Wed Feb 14, 2007 11:58 am Post subject: Reverting InstallLicense method |
|
|
Hello
our product is a collection of contols. It is sold in two versions: Full (ProductInfo "A") and Lite (ProductInfo "B").
Suppose a user buy a license for Lite version but try to enter the LicenseKey when using Full version. After a ProductInfo check, a popup message inform the user that the LicenseKey is valid, but not valid for this version (Full) of the product.
Unfortunately, at this point the InstallLicenseKey method of LicenseInstallForm has already written the .lic file using LicenseProvider.InstallLicense.
The question is: how can I revert the LicenseProvider.InstallLicense and/or delete the created .lic file?
In other words, I should love a LicenseProvider.UNInstallLicense method!
Thank you. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Wed Feb 14, 2007 9:24 pm Post subject: |
|
|
Quote: | In other words, I should love a LicenseProvider.UNInstallLicense method |
We will look at adding this in the next release - it is easy to implement yourself by simply deleting the lic file. In your scenario however, I don't think you need it.
If your Full and Lite versions use the same codebase (which is generally desirable in cases like this so that you don't have to generate two separate releases with separate installers) then your license key would just contain ProductInfo that indicates which version is supported. Your licensing code then checks and stores this and disable certain features if it is a Lite license.
If the Full and Lite version use different codebases then you should probably use a different Product password for each product and so you won't get the issue of installing a license which isn't valid. _________________ Infralution Support |
|
Back to top |
|
|
greek
Joined: 07 Feb 2007 Posts: 7
|
Posted: Thu Feb 15, 2007 4:38 am Post subject: |
|
|
Thank you for the reply.
Infralution wrote: | it is easy to implement yourself by simply deleting the lic file. |
I have no found a way to get the fully qualified file name of the .lic file. Could you please suggest me how to achieve this?
Infralution wrote: | Your licensing code then checks and stores this and disable certain features if it is a Lite license.
If the Full and Lite version use different codebases then you should probably use a different Product password for each product and so you won't get the issue of installing a license which isn't valid. | I use the same codebase, but I generate different setup using compiler variables.
Since I'm developing a collection of controls, it's hard to enable/disable some features according the license because controls must appears or not in the toolbox.
Furthermore, a license for Lite version is valid for Lite version only, but a license for Full version is valid for both versions. So, I must use the same password and perform a check using ProductInfo.
Thank you |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Feb 15, 2007 6:58 am Post subject: |
|
|
Quote: | I have no found a way to get the fully qualified file name of the .lic file. Could you please suggest me how to achieve this? |
If you are developing a library of controls then I would suggest not using the default license file location (which is in the same directory as the DLL/EXE) as this does not work well under Visual Studio 2005. In 2003 it was OK because the DLL's registered in the GAC retained information about their codebase and so the license file would end up next to the non-GAC version of the DLL. In 2005 however this codebase information is no longer stored and the license file ends up in the (hidden) GAC directory. If you reregister the DLL in the GAC (say during installation) then the hidden GAC directory gets deleted along with your license file.
Instead of this you should override GetLicenseDirectory to return the directory you want the license to be stored in (using the Shared data folder is a good option) eg
Code: | protected override string GetLicenseDirectory(LicenseContext context, Type type)
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData);
path += @"\MyCompany";
Directory.CreateDirectory(path); // ensure the directory exists
return path;
} |
I would also override the GetLicenseFilePath method as well to set the file name for the license file explicitly so that all your controls read the same license file.
Code: | protected override string GetLicenseFilePath(LicenseContext context, Type type)
{
string directory = GetLicenseDirectory(context, type);
return directory + "\\MyControls.lic";
} |
Quote: | Furthermore, a license for Lite version is valid for Lite version only, but a license for Full version is valid for both versions. So, I must use the same password and perform a check using ProductInfo. |
Another way of handling this that avoids having to delete the file when you find it is the wrong license would be to override the EncryptedLicenseProvider.LoadLicense method. This is the internal method that decrypts the license and returns the license containing product info. In your overrided method call the base method to decrypt license key then check that the ProductInfo in the returned license key is correct. If it doesn't match then you can return null. This way the license will never get installed for the wrong product in the first place. _________________ Infralution Support |
|
Back to top |
|
|
greek
Joined: 07 Feb 2007 Posts: 7
|
Posted: Thu Feb 15, 2007 7:33 am Post subject: |
|
|
Thank you for the patience and for the valuable informations and suggestions.
It's a pleasure work with you
Regards. |
|
Back to top |
|
|
|