This document is archived and information here might be outdated.  Recommended version.

How to programmatically handle LicenseControl initialization failure (ArcObjects .NET 10.8 SDK)
ArcObjects Help for .NET developers > ArcObjects Help for .NET developers > Developing with ArcGIS > Building stand-alone applications > Using the Winforms ArcGIS Engine controls > Using the LicenseControl > How to programmatically handle LicenseControl initialization failure

How to programmatically handle LicenseControl initialization failure

This article shows how to programmatically handle license initialization failure when using the LicenseControl. The ILicenseControl, LicenseAvailability, Status, and Summary methods are used to obtain information on the nature of the failure to report to the user before an application is programmatically shut down. Alternatively, the ShowStatusDialog method could be used to display a License Failure dialog box similar to the dialog box that appears when the LicenseControl automatically handles license initialization failure.

Handling the LicenseControl initialization failure

  1. Right-click the LicenseControl, then choose Properties to open the LicenseControl Properties dialog box.
  2. Select the appropriate check box for the product and extension licenses.
  3. Clear the Shutdown this application if the selected licenses are not available check box, then click the Apply button. See the following screen shot:

  4. Add code to import the following namespaces. See the following code:
Imports ESRI.ArcGIS.Controls
Imports ESRI.ArcGIS.esriSystem
using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;
  1. Place the following code at the beginning of the application before any other ArcObjects components are run, such as at the beginning in a Sub Main() or a Form_Load():
Dim sFailure As String, sAvailability() As String, i As Integer

'If license initialization failed,
If AxLicenseControl1.Status <> esriLicenseStatus.esriLicenseCheckedOut Then
    sFailure="License initialization failed for the following reason:" + _
               Environment.NewLine + AxLicenseControl1.Summary + Environment.NewLine + Environment.NewLine + _
               "The status of the requested license(s) is as follows:"
    'get the status of the requested licenses.
    For i=0 To sAvailability.Length - 1
        sFailure=sFailure + Environment.NewLine + sAvailability(i)
    Next i
    'Report failure to user.
    System.Windows.Forms.MessageBox.Show(sFailure, "LicenseControl", MessageBoxButtons.OK)
    'Programmatically shut down the application...
End If
//If license initialization failed,
if (axLicenseControl1.Status != esriLicenseStatus.esriLicenseCheckedOut)
    string failure="License initialization failed for the following reason:" +
        Environment.NewLine + axLicenseControl1.Summary + Environment.NewLine +
        Environment.NewLine + "The status" + 
        "of the requested license(s) is as follows:";

    //get the status of the requested licenses.
    string[] availability=axLicenseControl1.get_LicenseAvailability
    for (int i=0; i <= availability.Length - 1; i++)
        failure=failure + Environment.NewLine + availability[i];

    //Report failure to user.
    System.Windows.Forms.MessageBox.Show(failure, "LicenseControl",

    //Programmatically shut down the application...

See Also:

LicenseControl Class

To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
Engine Developer Kit Engine
ArcGIS for Desktop Basic
ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced