When you register a license for DeployLX by populating the SerialNumbers collection of the LicenseValidationRequestInfo class DeployLX will return the first license it finds that can be unlocked with the given serial numbers.
The next time you call Validate without populating the SerialNumbers collection, DeployLX returns a a trial license, or throws an exception that a valid license cannot be found.
This is by design.
When you populate the SerialNumbers collection you are telling DeployLX that you want to control the serial numbers in use for the application. So it does not store the serial number and expects it to be provided each time.
This is to support redistributable assemblies (such as UI controls) where the application developer will use controls from a publisher, but their customers should not be allowed to use those controls. So the application developer will embed their serial number into their application, passing it each time they create an instance of the protected control.
Read more about Support Redistributable Assemblies
If your design does not match the redistributable scenario, but you want to pass the serial number to your calls to Validate, there are two possible solutions.
The first solution is to store the serial number in your application's configuration settings. Visual Studio makes it easy to create application and user settings that you can use to store the data, or you can fall back on the traditional .config files and a custom section handler.
When validating, you will load the serial number from the application configuration and pass it each time you call Validate.
Public Sub Validate() Dim info = New LicenseValidationRequestInfo With { _ .SerialNumbers = GetApplicationSerialNumbers()} _license = SecureLicenseManager.Validate(Me, Nothing, info) End Sub Private Function GetApplicationSerialNumbers() As String() Dim serial = ConfigurationManager.AppSettings("SerialNumber") If serial Is Nothing Then Return Nothing End If Return { serial } End Function
public void Validate() { var info = new LicenseValidationRequestInfo { SerialNumbers = GetApplicationSerialNumbers() }; _license = SecureLicenseManager.Validate( this, null, info ); } private string[] GetApplicationSerialNumbers() { var serial = ConfigurationManager.AppSettings["SerialNumber"]; if( serial == null ) return null; return new []{ serial }; }
For an ASP.NET application, you might check if a serial number has been entered and redirect to a registration page if it hasn't. There you can prompt the user for their serial number and store it for later calls to Validate.
Private Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) If GetApplicationSerialNumbers() Is Nothing Then Response.Redirect("Register.aspx", True) End If End Sub
private void Page_Load( object sender, EventArgs e ) { if( GetApplicationSerialNumbers() == null ) Response.Redirect( "Register.aspx", true ); }
requires v4.0A second option is to also populate the SaveExternalSerials property. This will tell DeployLX to save the serial number as if it had been entered into the registration form.
Public Sub Validate(ByVal serials() As String) Dim info = New LicenseValidationRequestInfo() If serials IsNot Nothing Then info.SerialNumbers = serials info.SaveExternalSerials = True End If _license = SecureLicenseManager.Validate(Me, Nothing, info) End Sub
public void Validate( string[] serials ) { var info = new LicenseValidationRequestInfo(); if( serials != null ) { info.SerialNumbers = serials; info.SaveExternalSerials = true; }; _license = SecureLicenseManager.Validate( this, null, info ); }