http://backend.userland.com/rss092LogicNP Software Knowledge Base And FAQsupport@ssware.comsupport@ssware.com10/18/2025 6:14:02 AMCryptoLicensing For .Net :: Integration of CryptoLicensing With FastSpring
<span class="postbody">CryptoLicensing includes a ready-to-use license generator for FastSpring which you can use for automatic order-fulfillment and license delivery whenever your customers purchase your product via FastSpring.
<br />
<br />
<span style="font-weight: bold">The basic workflow is as follows:
<br />
</span>
<br />
1. Your FastSpring account is setup to ping your license service e-commerce page (<license-service-url>/ecommerce/fastspring.aspx) whenever any purchase occurs.
<br />
<br />
2. User purchases your software via FastSpring.
<br />
<br />
3. FastSpring pings (using HTTP POST) your license service e-commerce page with details of the purchase (name, email, product-id, product-name, verification/validation info, etc)
<br />
<br />
4. The e-commerce page uses the passed info to generate a new license using the CryptoLicensing Generator API and send it to the email address provided by the customer and/or return it as the response of the HTTP POST.
<br />
<br />
<br />
<span style="font-weight: bold">Here the steps required to achieve above workflow this:</span>
<br />
<br />
1. Create license service for your project
<br />
<br />
2. The FastSpring specific license generator files are fastspring.aspx and fastspring.aspx.cs (or fastspring.aspx.vb if using VB.Net) found in the 'ecommerce' sub-folder under the folder where you created the license service files above. The fastspring.aspx is an empty shell file and can be ignored. The fastspring.aspx.cs (or fastspring.aspx.vb if using VB.Net) contains the code to handle notifications from FastSpring and automatically generate and return licenses.
<br />
<br />
3. Change the settings in the fastspring.aspx.cs (or fastspring.aspx.vb if using VB.Net) as per your needs. The settings are found between the // START SETTINGS and // END SETTINGS lines.
<br />
<br />
4. Upload the license service folder to your web site and configure it. If you are only using e-commerce integration functionality, you do not need to perform the database related configuration.
<br />
<br />
5. Login to your FastSpring account and specify the URL of your license generator as follows: FastSpring Control Panel --> Remote License Configuration --> General. Specify the URL of your license generator. For example, if you uploaded to a sub-folder named 'LicenseService' on the domain 'http://www.mywebsite.com', the URL for the FastSpring integration will then be: <a href="http://www.mywebsite.com/LicenseService/ecommerce/fastspring.aspx" target="_blank">http://www.mywebsite.com/LicenseService/ecommerce/fastspring.aspx</a>
<br />
<br />
<span style="font-weight: bold">Notes</span>
<br />
<br />
* You can use the 'Run Test' feature of FastSpring to test the whole scheme.
<br />
<br />
* The e-commerce pages and the corresponding code-behind files are just starter pages with basic functionality to get you started. Most of the pages extract some HTTP variables from the request stream or the query string, and generate and return a new license. It certainly does not address any advanced scenarios of license generation or any other customization that you might require. However, you should be able to easily modify the existing code-behind files to suit your needs and requirements.
<br />
<br />
* If any errors/exceptions occur in the e-commerce page, then an exception message and stack trace is logged to the App_Data folder. Each exception is logged to its own text file having following name: exception_dd-MMM-yyyy_HH.mm.txt. You can use this for trouble-shooting purposes. To turn off this logging, set the log_exceptions variable in the corresponding aspx code-behind file to false (the default is true).
</span><br />
CryptoLicensing For .Net :: HOWTO: Perform activation of a license on behalf of a customer
<span class="postbody">If some customer does not have an Internet connection, you may wish to perform an activation on behalf of a customer. The procedure to do this is as follows:
<br />
<br />
1. In the CryptoLicensing UI, paste the customer's license code (generated with the "Limit Machines To" setting) in the bottom text box.
<br />
<br />
2. From the "Machine Code Provider" tab, select the "Explicitly Specified Machine Code" provider, and paste the machine code for the customer's machine which needs to be activated. Note: Use the <span style="font-weight: bold">CryptoLicense.GetLocalMachineCodeAsString</span> method from your software and display the value returned by this method to the customer for him to Copy-Paste and send to you.
<br />
<br />
3. Click the "Validate License/Serial" button. The UI will communicate with the license service to activate the license code using the customer's machine code. After activation, the bottom text box will display the machine-locked license code returned by the license service. Send this license code back to the customer.
<br />
<br />
The same procedure can be done via the <span style="font-weight: bold">Generator API</span> using following code:
<br />
<span style="font-weight: bold">[C#]</span>
<br />
</span><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>Code:</b></span></td> </tr> <tr> <td class="code">
<br />
string ActivateLicenseOnCustomerBehalf(string customer_license_code, string customer_machine_code)
<br />
{
<br />
CustomCryptoLicense lic = new CustomCryptoLicense(customer_machine_code);
<br />
lic.LicenseCode = customer_license_code;
<br />
lic.ValidationKey = "..."; // Set to actual
<br />
lic.LicenseServiceURL = "..."; // Set to actual
<br />
<br />
// Handle the OnGetLocalMachineCode event to provide the customer's machine code during activation.
<br />
lic.OnGetLocalMachineCode += (o, e) => { e.MachineCode = Convert.FromBase64String(customer_machine_code); e.Handled = true; };
<br />
<br />
LicenseStatus status = lic.Status; // Validate (activate) the license code
<br />
<br />
return lic.LicenseCode; // This now contains the machine-locked license code returned by the license service
<br />
}
<br />
<br />
</td> </tr></table><span class="postbody">
<br />
<span style="font-weight: bold">
<br />
[VB.NET]</span>
<br />
</span><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>Code:</b></span></td> </tr> <tr> <td class="code">
<br />
<br />
Private Function ActivateLicenseOnCustomerBehalf(customer_license_code As String, customer_machine_code As String) As String
<br />
<br />
Dim lic As New CustomCryptoLicense(customer_machine_code)
<br />
lic.LicenseCode = customer_license_code
<br />
lic.ValidationKey = "..." ' Set to actual
<br />
lic.LicenseServiceURL = "..." ' Set to actual
<br />
<br />
<br />
' Handle the OnGetLocalMachineCode event to provide the customer's machine code during activation.
<br />
AddHandler lic.OnGetLocalMachineCode,
<br />
Sub(o As Object, args As GetLocalMachineCodeEventArgs)
<br />
args.MachineCode = Convert.FromBase64String(customer_machine_code)
<br />
args.Handled = True
<br />
End Sub
<br />
<br />
Dim status As LicenseStatus = lic.Status ' Validate (activate) the license code
<br />
Return lic.LicenseCode ' This now contains the machine-locked license code returned by the license service
<br />
<br />
End Function
<br />
</td> </tr></table><span class="postbody">
</span><br />
CryptoLicensing For ActiveX :: HOWTO: Access license settings without validating the license.
<span class="postbody">When the <span style="font-weight: bold">CryptoLicense.Status</span> property is accessed , license validation occurs which is performed in two steps. First, cryptographic validation occurs which means the cryptographic signature of the license code is verified using the validation key specified via the <span style="font-weight: bold">CryptoLicense.ValidationKey</span> property. Next, any limits/settings specified in the license code are validated; for example if the license code specifies a "Max Activations" setting, then CryptoLicensing automatically communicates with the license service to activate the license.
<br />
<br />
However, under certain circumstances, you may want to simply access license settings without actually validating the license. To do this, first ensure that the license code is cryptographically valid by calling the <span style="font-weight: bold">CryptoLicense.ValidateSignature</span> method. Next, you can access the properties like <span style="font-weight: bold">CryptoLicense.UserData</span> (to access the embeded user-data), <span style="font-weight: bold">CryptoLicense.MaxActivations</span>, <span style="font-weight: bold">CryptoLicense.MaxUsageDays</span>, etc.
</span><br />
CryptoLicensing For MFC :: HOWTO: Access license settings without validating the license.
<span class="postbody">When the <span style="font-weight: bold">CCryptoLicense.GetStatus()</span> method is accessed, license validation occurs which is performed in two steps. First, cryptographic validation occurs which means the cryptographic signature of the license code is verified using the validation key specified via the <span style="font-weight: bold">CCryptoLicense.SetValidationKey() </span> method. Next, any limits/settings specified in the license code are validated; for example if the license code specifies a "Max Activations" setting, then CryptoLicensing automatically communicates with the license service to activate the license.
<br />
<br />
However, under certain circumstances, you may want to simply access license settings without actually validating the license. To do this, first ensure that the license code is cryptographically valid by calling the <span style="font-weight: bold">CCryptoLicense.ValidateSignature()</span> method. Next, you can access the methods like <span style="font-weight: bold">CCryptoLicense.GetUserData() </span> (to access the embeded user-data), <span style="font-weight: bold">CCryptoLicense.GetMaxActivations()</span>, <span style="font-weight: bold">CCryptoLicense.GetMaxUsageDays()</span>, etc.
</span><br />
CryptoLicensing For .Net :: HOWTO: Access license settings without validating the license.
<span class="postbody">When the <span style="font-weight: bold">CryptoLicense.Status</span> property is accessed , license validation occurs which is performed in two steps. First, cryptographic validation occurs which means the cryptographic signature of the license code is verified using the validation key specified via the <span style="font-weight: bold">CryptoLicense.ValidationKey</span> property. Next, any limits/settings specified in the license code are validated; for example if the license code specifies a "Max Activations" setting, then CryptoLicensing automatically communicates with the license service to activate the license.
<br />
<br />
However, under certain circumstances, you may want to simply access license settings without actually validating the license. To do this, first ensure that the license code is cryptographically valid by calling the <span style="font-weight: bold">CryptoLicense.ValidateSignature</span> method. Next, you can access the properties like <span style="font-weight: bold">CryptoLicense.UserData</span> (to access the embeded user-data), <span style="font-weight: bold">CryptoLicense.MaxActivations</span>, <span style="font-weight: bold">CryptoLicense.MaxUsageDays</span>, etc
</span><br />
CryptoLicensing For ActiveX :: HOWTO: View settings specified by a license code
<span class="postbody">To view the settings specified by a specific license code using the CryptoLicensing Generator UI:
<br />
<br />
1. Paste the license code in the <span style="font-weight: bold">Licenses</span> text box at the bottom.
<br />
2. Click the <span style="font-weight: bold">Show License Settings</span> button.
<br />
<br />
All the license settings will now be shown using the corresponding UI controls . If the license has any embedded user-data, that user-data will be show in the <span style="font-weight: bold">License User Data</span> tab using the currently active <span style="font-weight: bold">User Data Provider</span>.
</span><br />
CryptoLicensing For MFC :: HOWTO: View settings specified by a license code
<span class="postbody">To view the settings specified by a specific license code using the CryptoLicensing Generator UI:
<br />
<br />
1. Paste the license code in the <span style="font-weight: bold">Licenses</span> text box at the bottom.
<br />
2. Click the <span style="font-weight: bold">Show License Settings</span> button.
<br />
<br />
All the license settings will now be shown using the corresponding UI controls . If the license has any embedded user-data, that user-data will be show in the <span style="font-weight: bold">License User Data</span> tab using the currently active <span style="font-weight: bold">User Data Provider</span>.
</span><br />
CryptoLicensing For ActiveX :: INFO: Why do I see CryptoLicense.MaxActivations as 32766 instead of the value I specified while generating the license?
<span class="postbody">When this license code with the <span style="font-weight: bold">MaxActivations (Limit Machines To)</span> setting is validated, the license service returns a new license code which has all the same settings as the original license, except:
<br />
- The new license is machine-locked to the machine from which the activation took place. This ensures that the newly returned license only works on that machine.
<br />
- The new license has its <span style="font-weight: bold">MaxActivations (Limit Machines To) </span>setting removed. This ensures that the next time the license is loaded, it is not necessary to communicate with the license service to activate the license again, since the license is already machine-locked.
<br />
<br />
The reason the <span style="font-weight: bold">CryptoLicense.MaxActivations </span>property returns 32766 is because you are accessing that property <span style="font-weight: bold">AFTER </span>validation the license - in effect you are querying the properties of the new license code returned by the license service. As described above, this license code does not have the MaxActivations setting.
<br />
<br />
To get the MaxActivations setting of the original license code, load it into a CryptoLicense object, and then access the MaxActivations property.
</span><br />
CryptoLicensing For MFC :: INFO: Why do I see CCryptoLicense.GetMaxActivations() as 32766 instead of the value I specified while generating the license?
<span class="postbody">When this license code with the <span style="font-weight: bold">MaxActivations (Limit Machines To)</span> setting is validated, the license service returns a new license code which has all the same settings as the original license, except:
<br />
- The new license is machine-locked to the machine from which the activation took place. This ensures that the newly returned license only works on that machine.
<br />
- The new license has its <span style="font-weight: bold">MaxActivations (Limit Machines To) </span>setting removed. This ensures that the next time the license is loaded, it is not necessary to communicate with the license service to activate the license again, since the license is already machine-locked.
<br />
<br />
The reason the <span style="font-weight: bold">CryptoLicense.GetMaxActivations() </span>method returns 32766 is because you are accessing that property <span style="font-weight: bold">AFTER </span>validation the license - in effect you are querying the properties of the new license code returned by the license service. As described above, this license code does not have the MaxActivations setting.
<br />
<br />
To get the MaxActivations setting of the original license code, load it into a CCryptoLicense object, and then use the CCryptoLicense.GetMaxActivations() method.
</span><br />
CryptoLicensing For .Net :: INFO: Why do I see CryptoLicense.MaxActivations as 32766 instead of the value I specified while generating the license?
<span class="postbody">When this license code with the <span style="font-weight: bold">MaxActivations (Limit Machines To)</span> setting is validated, the license service returns a new license code which has all the same settings as the original license, except:
<br />
- The new license is machine-locked to the machine from which the activation took place. This ensures that the newly returned license only works on that machine.
<br />
- The new license has its <span style="font-weight: bold">MaxActivations (Limit Machines To) </span>setting removed. This ensures that the next time the license is loaded, it is not necessary to communicate with the license service to activate the license again, since the license is already machine-locked.
<br />
<br />
The reason the <span style="font-weight: bold">CryptoLicense.MaxActivations </span>property returns 32766 is because you are accessing that property <span style="font-weight: bold">AFTER </span>validation the license - in effect you are querying the properties of the new license code returned by the license service. As described above, this license code does not have the MaxActivations setting.
<br />
<br />
To get the MaxActivations setting of the original license code, load it into a CryptoLicense object, and then access the MaxActivations property.
</span><br />
CryptoLicensing For .Net :: HOWTO: View settings specified by a license code
<span class="postbody">To view the settings specified by a specific license code using the CryptoLicensing Generator UI:
<br />
<br />
1. Paste the license code in the <span style="font-weight: bold">Licenses</span> text box at the bottom.
<br />
2. Click the <span style="font-weight: bold">Show License Settings</span> button.
<br />
<br />
All the license settings will now be shown using the corresponding UI controls . If the license has any embedded user-data, that user-data will be show in the <span style="font-weight: bold">License User Data</span> tab using the currently active <span style="font-weight: bold">User Data Provider</span>.
</span><br />
Crypto Obfuscator For .Net :: INFO: Common Exception Reporting Service related issues and their solutions
<span class="postbody">1. Did you specify the correct service URL which is <span style="font-weight: bold">http://MyServiceBaseURL/Service.asmx</span>
<br />
<br />
2. When obfuscating your assemblies, did you specify the above URL in the <span style="font-weight: bold">Exception Reporting tab</span>?.
<br />
<br />
3. Did you give read-write permissions to the App_Data folder? Please see the topic <span style="font-weight: bold">Crypto Obfuscator UI Reference: Create Exception Reporting Service Dialog</span> in the help file for detailed instructions.
<br />
<br />
4. Can you see a list of service operations when you access the exception reporting service URL from your browser?
<br />
<br />
5. If the service is still not working properly, check for any exceptions that might be occurring when the service runs. The service will log exceptions to the App_Data folder. This facilitates trouble-shooting and diagnosing any problems with the service.
<br />
<br />
Each exception is logged to its own file having following name: "exception_dd-MMM-yyyy_HH.mm.txt".
<br />
<br />
Note: To disable exception logging, set the ExceptionReportingService.LogExceptions property to False in the ExceptionReportingService.cs file as follows:
<br />
<br />
C#
<br />
</span><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>Code:</b></span></td> </tr> <tr> <td class="code"> public ExceptionReportingServiceClass()
<br />
{
<br />
<br />
this.LogExceptions=false;
<br />
<br />
}</td> </tr></table><span class="postbody">
<br />
<br />
VB.Net
<br />
</span><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>Code:</b></span></td> </tr> <tr> <td class="code"> Public Sub New()
<br />
<br />
Me.LogExceptions = False
<br />
<br />
End Sub</td> </tr></table><span class="postbody">
</span><br />
CryptoLicensing For ActiveX :: INFO: Retrieving additional information about license validation failures.
<span class="postbody">License validation can fail due to any number of reasons. For example, any license settings which require communication with the license service (for example, Max Activations) will fail if the license service is not reachable. To determine the underlying cause of the validation failure, use the CryptoLicense.GetStatusExceptionMessage method. This method can be used as follows:
<br />
<br />
</span><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>Code:</b></span></td> </tr> <tr> <td class="code">Function GetAllStatusExceptionsAsString() As String
<br />
<br />
Dim ret As String
<br />
Dim status As Long
<br />
status = 1
<br />
<br />
While status < LicenseStatus.LS_LicenseServerMachineCodeInvalid ' highest possible status code
<br />
<br />
Dim tmp As String
<br />
tmp = appLicense.GetStatusExceptionMessage(status)
<br />
<br />
If Len(tmp) > 0 Then ' Additional info available for the status
<br />
<br />
If (Len(ret) > 0) Then ret = ret & Chr(10) & Chr(13)
<br />
ret = ret & GetStatusAsString(status) & ": " & tmp
<br />
<br />
End If
<br />
<br />
status = status * 2 ' next status code
<br />
<br />
Wend
<br />
<br />
GetAllStatusExceptionsAsString = ret
<br />
<br />
End Function
<br />
<br />
Function GetStatusAsString(status As Long) As String
<br />
<br />
Select Case status
<br />
<br />
Case LicenseStatus.LS_ActivationFailed: GetStatusAsString = "ActivationFailed"
<br />
Case LicenseStatus.LS_CumulativeRunTimeExceeded: GetStatusAsString = "CumulativeRunTimeExceeded"
<br />
Case LicenseStatus.LS_DateRollbackDetected: GetStatusAsString = "DateRollbackDetected"
<br />
Case LicenseStatus.LS_Deactivated: GetStatusAsString = "Deactivated"
<br />
Case LicenseStatus.LS_DebuggerDetected: GetStatusAsString = "DebuggerDetected"
<br />
Case LicenseStatus.LS_EvaluationExpired: GetStatusAsString = "EvaluationExpired"
<br />
Case LicenseStatus.LS_ExecutionsExceeded: GetStatusAsString = "ExecutionsExceeded"
<br />
Case LicenseStatus.LS_Expired: GetStatusAsString = "Expired"
<br />
Case LicenseStatus.LS_GenericFailure: GetStatusAsString = "GenericFailure"
<br />
Case LicenseStatus.LS_InstancesExceeded: GetStatusAsString = "InstancesExceeded"
<br />
Case LicenseStatus.LS_LicenseServerMachineCodeInvalid: GetStatusAsString = "LicenseServerMachineCodeInvalid"
<br />
Case LicenseStatus.LS_LocalTimeInvalid: GetStatusAsString = "LocalTimeInvalid"
<br />
Case LicenseStatus.LS_MachineCodeInvalid: GetStatusAsString = "MachineCodeInvalid"
<br />
Case LicenseStatus.LS_RemoteSessionDetected: GetStatusAsString = "RemoteSessionDetected"
<br />
Case LicenseStatus.LS_RunTimeExceeded: GetStatusAsString = "RunTimeExceeded"
<br />
Case LicenseStatus.LS_SerialCodeInvalid: GetStatusAsString = "SerialCodeInvalid"
<br />
Case LicenseStatus.LS_ServiceNotificationFailed: GetStatusAsString = "ServiceNotificationFailed"
<br />
Case LicenseStatus.LS_SignatureInvalid: GetStatusAsString = "SignatureInvalid"
<br />
Case LicenseStatus.LS_UniqueUsageDaysExceeded: GetStatusAsString = "UniqueUsageDaysExceeded"
<br />
Case LicenseStatus.LS_UsageDaysExceeded: GetStatusAsString = "UsageDaysExceeded"
<br />
Case LicenseStatus.LS_UsageModeInvalid: GetStatusAsString = "UsageModeInvalid"
<br />
End Select
<br />
<br />
End Function
<br />
</td> </tr></table><span class="postbody">
</span><br />
CryptoLicensing For MFC :: INFO: Retrieving additional information about license validation failures.
<span class="postbody">License validation can fail due to any number of reasons. For example, any license settings which require communication with the license service (for example, Max Activations) will fail if the license service is not reachable. To determine the underlying cause of the validation failure, use the CCryptoLicense.GetStatusExceptionMessage() method. This method can be used as follows:
<br />
</span><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>Code:</b></span></td> </tr> <tr> <td class="code">
<br />
CString CAppLicensingDlg::GetStatusAsString(int status)
<br />
{
<br />
CString str;
<br />
switch (status)
<br />
{
<br />
case LS_ActivationFailed:
<br />
str = _T("ActivationFailed");
<br />
break;
<br />
case LS_CumulativeRunTimeExceeded:
<br />
str = _T("CumulativeRunTimeExceeded");
<br />
break;
<br />
case LS_DateRollbackDetected:
<br />
str = _T("DateRollbackDetected");
<br />
break;
<br />
case LS_Deactivated:
<br />
str = _T("Deactivated");
<br />
break;
<br />
case LS_DebuggerDetected:
<br />
str = _T("DebuggerDetected");
<br />
break;
<br />
case LS_EvaluationExpired:
<br />
str = _T("EvaluationExpired");
<br />
break;
<br />
case LS_ExecutionsExceeded:
<br />
str = _T("ExecutionsExceeded");
<br />
break;
<br />
case LS_Expired:
<br />
str = _T("Expired");
<br />
break;
<br />
case LS_GenericFailure:
<br />
str = _T("GenericFailure");
<br />
break;
<br />
case LS_InstancesExceeded:
<br />
str = _T("InstancesExceeded");
<br />
break;
<br />
case LS_LicenseServerMachineCodeInvalid:
<br />
str = _T("LicenseServerMachineCodeInvalid");
<br />
break;
<br />
case LS_LocalTimeInvalid:
<br />
str = _T("LocalTimeInvalid");
<br />
break;
<br />
case LS_MachineCodeInvalid:
<br />
str = _T("MachineCodeInvalid");
<br />
break;
<br />
case LS_RemoteSessionDetected:
<br />
str = _T("RemoteSessionDetected");
<br />
break;
<br />
case LS_RunTimeExceeded:
<br />
str = _T("RunTimeExceeded");
<br />
break;
<br />
case LS_SerialCodeInvalid:
<br />
str = _T("SerialCodeInvalid");
<br />
break;
<br />
case LS_ServiceNotificationFailed:
<br />
str = _T("ServiceNotificationFailed");
<br />
break;
<br />
case LS_SignatureInvalid:
<br />
str = _T("SignatureInvalid");
<br />
break;
<br />
case LS_UniqueUsageDaysExceeded:
<br />
str = _T("UniqueUsageDaysExceeded");
<br />
break;
<br />
case LS_UsageDaysExceeded:
<br />
str = _T("UsageDaysExceeded");
<br />
break;
<br />
case LS_UsageModeInvalid:
<br />
str = _T("UsageModeInvalid");
<br />
break;
<br />
}
<br />
return str;
<br />
}
<br />
<br />
CString CAppLicensingDlg::GetAllStatusExceptionsAsString(CCryptoLicense* license)
<br />
{
<br />
CString ret;
<br />
int status;
<br />
<br />
status = 1;
<br />
<br />
while(status < LS_LicenseServerMachineCodeInvalid) // highest possible status code
<br />
{
<br />
CString tmp;
<br />
tmp = license->GetStatusExceptionMessage(status);
<br />
if (tmp.GetLength() > 0) // Additional info available for the status
<br />
{
<br />
if (ret.GetLength() > 0)
<br />
ret = ret + _T("\r\n");
<br />
<br />
ret = ret + GetStatusAsString(status) + ": " + tmp;
<br />
}
<br />
<br />
status = status * 2; // next status code
<br />
}
<br />
<br />
return ret;
<br />
}</td> </tr></table><span class="postbody">
</span><br />
CryptoLicensing For .Net :: INFO: Retrieving additional information about license validation failures.
http://www.ssware.com/support/viewtopic.php?p=753#753
<span class="postbody">License validation can fail due to any number of reasons. For example, any license settings which require communication with the license service (for example, Max Activations) will fail if the license service is not reachable. To determine the underlying cause of the validation failure, use the CryptoLicense.GetStatusException method. This method can be used as follows:
<br />
<br />
</span><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>Code:</b></span></td> </tr> <tr> <td class="code"> string GetAllStatusExceptionsAsString(CryptoLicense license)
<br />
{
<br />
LicenseStatus[] status = (LicenseStatus[] )Enum.GetValues(typeof(LicenseStatus));
<br />
StringBuilder sb = new StringBuilder();
<br />
foreach (LicenseStatus ls in status)
<br />
{
<br />
Exception ex = license.GetStatusException(ls);
<br />
if (ex != null) // Additional info available for the status
<br />
{
<br />
if (sb.Length > 0)
<br />
sb.Append("\n");
<br />
<br />
sb.Append(ls.ToString());
<br />
sb.Append(": ");
<br />
sb.Append(ex.Message);
<br />
}
<br />
}
<br />
<br />
return sb.ToString();
<br />
}</td> </tr></table><span class="postbody">
<br />
<br />
<span style="font-weight: bold">[VB.Net]</span>
<br />
</span><table width="90%" cellspacing="1" cellpadding="3" border="0" align="center"><tr> <td><span class="genmed"><b>Code:</b></span></td> </tr> <tr> <td class="code">Function GetAllStatusExceptionsAsString(ByVal license As CryptoLicense) As String
<br />
<br />
Dim status As LicenseStatus() = DirectCast([Enum].GetValues(GetType(LicenseStatus)), LicenseStatus())
<br />
Dim sb As New StringBuilder()
<br />
<br />
For Each ls As LicenseStatus In status
<br />
Dim ex As Exception = license.GetStatusException(ls)
<br />
<br />
If ex IsNot Nothing Then
<br />
' Additional info available for the status
<br />
If sb.Length > 0 Then
<br />
sb.Append(vbLf)
<br />
End If
<br />
<br />
sb.Append(ls.ToString())
<br />
sb.Append(": ")
<br />
sb.Append(ex.Message)
<br />
End If
<br />
<br />
Next
<br />
<br />
Return sb.ToString()
<br />
<br />
End Function</td> </tr></table><span class="postbody">
</span><br />