Support
Joined: 18 Jul 2005 Posts: 731
|
Posted: Wed Feb 29, 2012 1:54 am Post subject: INFO: Retrieving additional information about license validation failures. |
|
|
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:
Code: | string GetAllStatusExceptionsAsString(CryptoLicense license)
{
LicenseStatus[] status = (LicenseStatus[] )Enum.GetValues(typeof(LicenseStatus));
StringBuilder sb = new StringBuilder();
foreach (LicenseStatus ls in status)
{
Exception ex = license.GetStatusException(ls);
if (ex != null) // Additional info available for the status
{
if (sb.Length > 0)
sb.Append("\n");
sb.Append(ls.ToString());
sb.Append(": ");
sb.Append(ex.Message);
}
}
return sb.ToString();
} |
[VB.Net]
Code: | Function GetAllStatusExceptionsAsString(ByVal license As CryptoLicense) As String
Dim status As LicenseStatus() = DirectCast([Enum].GetValues(GetType(LicenseStatus)), LicenseStatus())
Dim sb As New StringBuilder()
For Each ls As LicenseStatus In status
Dim ex As Exception = license.GetStatusException(ls)
If ex IsNot Nothing Then
' Additional info available for the status
If sb.Length > 0 Then
sb.Append(vbLf)
End If
sb.Append(ls.ToString())
sb.Append(": ")
sb.Append(ex.Message)
End If
Next
Return sb.ToString()
End Function |
|
|