View previous topic :: View next topic |
Author |
Message |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Sat Sep 06, 2014 1:34 am Post subject: Different types of licenses in one application |
|
|
I currently use only individual licenses in my application, but I plan to implement floating network licenses as well. I'm confused about how to do it. For example, when you generate a license key, how does License Tracker know what license type you want? In my application, do I need to add the two implementations and then use a logic like the following?
Code: | If (licenseType == "Individual")
{
// Individual implementation
}
else // Floating
{
// Floating implementation
} |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Sep 06, 2014 6:55 pm Post subject: |
|
|
The way the sample floating license project does this is by including the number of floating licenses in the ProductInfo field when the license key is generated. If this is set to a number (eg 1, 2, 3..) then the license is a floating license. If the ProductInfo field is not set then the license is not a floating license. _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Mon Sep 08, 2014 8:38 pm Post subject: |
|
|
Please correct me if I'm wrong. For a floating license, in addition to my application, the customer needs to download the License Service application, right? This is a little bit confusing.
In the sample projects you use the command line prompt to do the installation. Does the customer have to do the same, or how does he install the License Service? Do I need to use my installer, just as I do with my application? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Sep 09, 2014 7:28 am Post subject: |
|
|
Your installer needs to install both your application and the LicenseService executable. On the PC that is to act as license server your installer needs to register the service. The sample projects use the command line to register the service - because there are many different installer software packages and it is not possible for us to provide a full installation sample. You will need to consult your installer package documentation for information about registering windows services. _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Wed Sep 10, 2014 11:43 am Post subject: |
|
|
I can set my installer to do the installation (the /I option) and also to show the license install form (the /L option). However, if the client needs to have access to this form in the future to load, save or uninstall the license, there's not an easy way to do it. Then the client would have to call me, and at that point he would be instructed to open the command line prompt and use the /L option.
Is it possible to create a form with a menu, or a more elegant way for the client to access the license install form in the future? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Thu Sep 11, 2014 4:14 pm Post subject: |
|
|
You can have your installer add a menu entry to the Start Programs (eg called Install License) that calls the LicenseService with the /L parameter. _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Thu Sep 11, 2014 4:18 pm Post subject: |
|
|
OK. I have another question. The Floating License sample handles both the floating and the local license types. However, the sample doesn't do the background check for the local license. Is this on purpose? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Thu Sep 11, 2014 7:45 pm Post subject: |
|
|
One more question. Does local license mean authenticated license? If so, why LocalLicenseProvider is so different to AuthenticatedLicenseProvider? My current authenticated license implementation works fine, but it seems that the local license code is not the same. Please clarify. I use VS 2008, C#. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Sep 12, 2014 6:52 am Post subject: |
|
|
The LocalLicenseProvider inherits from AuthenticatedLicenseProvider and just overrides the AuthenticateKey method to ensure that the customer doesn't install a floating license as a fixed local license. Actually this is probably not necessary because it doesn't really matter if a customer chooses to do this.
The sample project doesn't use the Background Authentication check because it was originally designed to work with simple encrypted licenses. There is no reason why you cannot add a call to this at the bottom of LoadLocalLicense (see code below). You would also need to add a call to StopBackgroundAuthenticationCheck() after Application.Run() to ensure that your application exits.
Code: | private static bool LoadLocalLicense()
{
if (_localLicense == null)
{
_localLicense = _localLicenseProvider.GetLicense();
// check that the license isn't a floating license file
//
if (_localLicense != null)
{
if (!string.IsNullOrEmpty(_localLicense.ProductInfo))
{
MessageBox.Show(Resources.LocalFloatingLicenseErrorMsg, Resources.LicenseErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
_localLicense = null;
}
}
}
bool isValid = _localLicenseProvider.IsValid(_localLicense);
if (isValid)
{
_localLicenseProvider.StartBackgroundAuthenticationCheck(_localLicense);
}
return isValid;
} |
_________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Fri Sep 12, 2014 10:48 am Post subject: |
|
|
Thank you. The code would be like this:
Code: | Application.Run(new MainForm());
ReleaseFloatingLicense();
_localLicenseProvider.StopBackgroundAuthenticationCheck(); |
Note that the second line applies to floating licenses only and the third line applies to local licenses only. Can they co-exist as shown, or an If() statement is necessary? |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Sep 12, 2014 2:59 pm Post subject: |
|
|
That should work and should not need an If statement since the StopBackgroundAuthenticationCheck doesn't do anything if the check thread is not running, _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Sat Sep 13, 2014 1:17 pm Post subject: |
|
|
The following code from the sample FloatingLicenseApp only checks either floating or local installed license, depending on the default settings. If I have a local license installed but the default setting is floating, then it opens the evaluation dialog anyway, because LoadLicense() uses the default setting. Please check.
Code: | while (!LoadLicense())
{
EvaluationMonitor evaluationMonitor = new RegistryEvaluationMonitor("MyEvaluationPassword");
EvaluationDialog evaluationDialog = new EvaluationDialog();
EvaluationDialogResult dialogResult = evaluationDialog.ShowDialog(evaluationMonitor);
if (dialogResult == EvaluationDialogResult.Exit) return; // exit the app
if (dialogResult == EvaluationDialogResult.Continue) break; // exit the loop
if (dialogResult == EvaluationDialogResult.InstallLicense)
{
InstallLicense();
}
} |
|
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Sep 13, 2014 3:02 pm Post subject: |
|
|
Are you seeing an actual issue when testing or are you just looking at the code?
When a local license is installed by InstallLocalLicense() the Settings.Default.UseFloatingLicense property is set to false - so if a local license has been installed LoadLicense() will call LoadLocalLicense() and return true if a local license is installed. See the code below:
Code: | public static bool InstallLocalLicense()
{
// Display the license form and use our LocalLicenseProvider to check that
// they aren't incorrectly trying to install a floating license locally
//
AuthenticatedLicenseInstallForm licenseForm = new AuthenticatedLicenseInstallForm();
_localLicense = licenseForm.ShowDialog(_localLicenseProvider, _localLicense);
if (_localLicense != null)
{
Settings settings = Settings.Default;
settings.UseFloatingLicense = false;
settings.Save();
}
return _localLicense != null;
}
|
_________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Javier
Joined: 09 Oct 2009 Posts: 215
|
Posted: Sat Sep 13, 2014 3:51 pm Post subject: |
|
|
In my case the local license already exists, and if I send this to my clients they also have a local license installed. There should be a mechanism to detect a local license when InstallLocalLicense() has not been used. |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Sat Sep 13, 2014 4:06 pm Post subject: |
|
|
The sample project was designed for the case where you allowed for floating licenses from the start. In your case you could just change the default value for the UseFloatingLicense property from true to false. You do this by selectinfg the Properties > Settings node in the Solution explorer and setting the value. This will ensure that if a local license is already installed it will be picked up by default. _________________ Infralution Support |
|
Back to top |
|
![](templates/subSilver/images/spacer.gif) |
|