Cannot Acquire License from Trusted Storage After Restart
Summary
User is unable to acquire a license from trusted storage after restart.
Question
When using the FlexNet Embedded 2015 R2 .NET XT kit (though this also applies to other kits), you're having an issue with your network license implementation:
- The user connects to a network license server, licenses are requested, stored in trusted storage and acquired successfully from trusted storage.
- Then the user closes the app and restarts.
- On launch, they check trusted storage for features they've already leased from the server, using:
ILicensing.LicenseManager.GetFeatureCollection(LicenseSourceOption.TrustedStorage, true);" - This call returns a collection of their features from the last session indicating valid for acquisition.
- Realizing you have the features available for acquisition, you don't make a new request to the server.
- You then attempt to acquire licenses for the features using
"ILicensing.LicenseManager.Acquire();" - You receive the following error message:
A service system error was encountered: Requested feature was not found. [1,7E0,8,0[7000000B,0,702C7]]
So, why are you unable to acquire this feature that claims to be available for acquisition? And why, if you make a new request to the server for the features, then try to acquire, it works fine. Why is this happening?
Answer
The problem is that you are failing to add trusted storage as a license source before requesting the feature.
When a capability response is processed, trusted storage is automatically added as a license source (as indicated in the API documentation). A trusted storage license source for the target server instance will be added to the license source collection if not already present.
When the application restarts, the license source collection is empty: ILicensing.LicenseManager.GetFeatureCollection(LicenseSourceOption.TrustedStorage, true);"
API will return a feature collection of the features contained in trusted storage but will not add trusted storage as a license source for feature acquisition. In fact, the GetFeatureCollection method call as you coded with the diagnostic parameter set to true will return all trusted storage features both valid and invalid (such as expired, etc.).
To fix this, on restart, you need to explicitly add trusted storage as a license source before attempting to acquire the valid features contained within trusted storage:
ILicensing.LicenseManager.AddTrustedStorageLicenseSource()