Hi,
I’m attempting to create a super simple licensing option: I just want the user to type in a licensing key.
I tried following Creating Plugins that use the LAN Zoo with C#
Here is what I’m trying:
protected ValidateResult MyValidateProductKey(string productKey, out LicenseData licenseData) {
if (productKey == "hello123") {
licenseData = new LicenseData() { BuildType = LicenseBuildType.Beta, LicenseTitle = "heres a license" };
return ValidateResult.Success;
}
licenseData = new LicenseData() { BuildType = LicenseBuildType.Beta, LicenseTitle = "heres a license", ErrorMessage = "Invalid License Key." };
return ValidateResult.ErrorShowMessage;
}
protected void MyOnLeaseChangedDelegate(LicenseLeaseChangedEventArgs args, out System.Drawing.Icon icon) {
icon = new System.Drawing.Icon(PathStykkaIcon);
}
protected override LoadReturnCode OnLoad(ref string errorMessage)
{
// Check for a license
var valid = GetLicense(LicenseCapabilities.CanBeSpecified,"CCCCCCCCCCCCC", MyValidateProductKey, MyOnLeaseChangedDelegate);
if (valid) {
// Plugin Specific stuff here.
return base.OnLoad(ref errorMessage);
} else {
errorMessage = "Could not locate a valid license.";
return LoadReturnCode.ErrorShowDialog;
}
}
When running the above code, I get the Zoo License window popping up, and I’m able to enter a License Key. If it’s the wrong key, it refuses. If it’s the correct key, it closes the Zoo License window, and then reopens it again. It will do this 3 times. GetLicense
returns false
.
What am I doing wrong?