using ESRI.ArcGIS.Controls;
using ESRI.ArcGIS.esriSystem;
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():
[VB.NET]
Dim sFailure AsString, sAvailability() AsString, i AsInteger'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.
sAvailability = AxLicenseControl1.get_LicenseAvailability(esriLicenseStatusOptions.esriLicenseStatusRequested).Split(Environment.NewLine)
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... EndIf
[C#]
//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(esriLicenseStatusOptions.esriLicenseStatusRequested).Split(Environment.NewLine.ToCharArray());
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", MessageBoxButtons.OK);
//Programmatically shut down the application...
}