I am developing a plug-in for a third-party application which requires to use a System.LicenseProvider.
The License File itself is FlexLM generated.
so I have:
[LicenseProvider(typeof(LicFileLicenseProvider))]
public class MyLicensedModule
{
protected System.ComponentModel.License thisLicense;
protected ModuleFlexFeature thisfeature;
public bool LicenseCheck()
{
bool isLicensed = LicenseManager.IsLicensed(typeof(ModuleFlexFeature)); //returns TRUE
if(thisFeature==null) thisFeature = new ModuleFlexFeature();
thisLicense = LicenseManager.Validate(typeof(ModuleFlexFeature),thisFeature);
//no thrown exception
return (thisLicense != null); //thisLicense is always null
}
public void Dispose()
{
if (thisLicense!=null)
{
thisLicense.Dispose();
thisLicense = null;
}
}
}
(+ other irrelevant methods), using:
internal class ModuleFlexFeature
{
public ModuleFlexFeature() { }
public string FeatureName { get { return "myFlexLMFeature"; } }
public float FeatureVersion { get { return 2016.0f; } }
}
Using the LMTOOLS by Flexera, I can get the License Server Status (I am running on 7507@mypcname, 0 out of 1 license for myFlexLMFeature is used).
Then I can add 7507@mypcname in the extra servers to be used by the third party app, but:
- isLicensed returns true (expected)
- LicenseManager.Validate() does not throw exception (expected)
- thisLicense is null (not expected)
I've tried to use
LicenseManager.IsValid(typeof(ModuleFlexFeature),new ModuleFlexFeature(), out thisLicense);
but both have similar results (code seems to work but thisLicense is null)
Am I doing anything wrong ? is LicenseManager compatible with FlexLM ? or is there a bug on the third-party app which runs my plug-in (somehow does not connect to the license server properly)? How to check?
Thanks
OK, After some more investigation:
You cannot use a LicFileProvider to read FlexLMFiles
You have to create your own LicenseProvider and implement getLicense. To do this, you have to know where the file is / may be, and use lmutil. So first, you need to check if a license is available.
Inspired from this previous question, I have been able to get the following code to check if a license is valid or not (and detect, when several lm servers are used, which one to use):
This works fine... BUT this does not generate a license (this only checks if I can reasonably hope for one or not).
I've investigated lmborrow but it does not seem to generate a token either. Do you have any idea?