cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Not applicable

.NET Acquire from Trusted Storage can not find feature

When I try and do a LicenseManager.Acquire with license data from Trusted Storage, I get a Feature Not Found, even though I can see the feature in the collection. After I do a Capability Request, then the same feature can be found. The following is modified snippet from the CapabilityRequest.cs sample code. In the sample here, I get the first message saying the feature is found, but it fails in the first AcquireReturn sequence. After it processes the capability response, the second AcquireReturn is successful.

[FONT=Courier New]
using (licensing = LicensingFactory.GetLicensing(
IdentityClient.IdentityData,
strPath,
newHostId))
{
// The optional host name is typically set by a user as a friendly name for the host.
// The host name is not used for license enforcement.

// ** Set the machine name
licensing.LicenseManager.HostName = Environment.MachineName;
// The host type is typically a name set by the implementer, and is not modifiable by the user.
// While optional, the host type may be used in certain scenarios by some back-office systems such as FlexNet Operations.
licensing.LicenseManager.HostType = "FLX_CLIENT";

// Test code!
IFeatureCollection collection = licensing.LicenseManager.GetFeatureCollection(LicenseSourceOption.TrustedStorage);

var featFromCollection = (from feature in collection
where feature.Name == shcFeature
select feature).FirstOrDefault();
if (featFromCollection != null)
{
Util.DisplayInfoMessage(shcFeature + " version " + featFromCollection.Version + " found!");
}

AcquireReturn(shcFeature, shcVersion);

// create the capability request
ICapabilityRequestOptions options = licensing.LicenseManager.CreateCapabilityRequestOptions();
options.ForceResponse = true;

ICapabilityRequestData capabilityRequestData = licensing.LicenseManager.CreateCapabilityRequest(options);

byte[] binCapResponse = null;

// send the capability request to the server and receive the server response
Util.DisplayInfoMessage("Sending Capability Request");
CommFactory.Create(serverUrl).SendBinaryMessage(capabilityRequestData.ToArray(), out binCapResponse);
if (binCapResponse != null && binCapResponse.Length > 0)
{
Util.DisplayInfoMessage("Response received");
}
ICapabilityResponse response = licensing.LicenseManager.ProcessCapabilityResponse(binCapResponse);

AcquireReturn(shcFeature, shcVersion);
[/FONT]
Labels (1)
0 Kudos
(1) Reply
CSmith
Level 2

Hi Dale

It looks like you're missing the command to tell the licence manager to look in trusted storage for licence information. You need to do this:

licensing.LicenseManager.AddTrustedStorageLicenseSource();

before your first AcquireReturn() call.

I made the same mistake initially - I assumed that because I had passed a path for the trusted source into LicensingFactory.GetLicensing() that it would automatically be used. It is not.

Hope that helps.
CASmith
0 Kudos