After the ArcGIS Engine developer kit product and corresponding product licenses are installed, it is only for your application Program Implementing the features allowed by the license provides the possibility that you still need to initialize the license file to make your application have these features.
Note: If you do not perform this initialization, you may encounter a prompt that you do not have the required permission when implementing some features.
The initial test of this License file needs to be implemented at the entrance of your application. Below is the initialization of C # Code Example
Using ESRI. ArcGIS. esrisystem;
Namespace licenseinitializer
{
Public class licenseinitializer
{
Private iaoinitialize m_aoinitialize = new aoinitializeclass ();
Public bool initializeapplication ()
{
Bool binitialized = true;
If (m_aoinitialize = NULL)
{
System. Windows. Forms. MessageBox. Show ("unable to initialize. This application cannot run! ");
Binitialized = false;
}
// Initialize the application
Esrilicensestatus licensestatus = esrilicensestatus. esrilicenseunavailable;
Licensestatus = checkoutlicenses (esrilicenseproductcode. esrilicenseproductcodeengine );
If (licensestatus! = Esrilicensestatus. esrilicensecheckedout)
{
Licensestatus = checkoutlicenses (esrilicenseproductcode. esrilicenseproductcodearcview );
If (licensestatus! = Esrilicensestatus. esrilicensecheckedout)
{
Licensestatus = checkoutlicenses (esrilicenseproductcode. esrilicenseproductcodearceditor );
If (licensestatus! = Esrilicensestatus. esrilicensecheckedout)
{
Licensestatus = checkoutlicenses (esrilicenseproductcode. esrilicenseproductcodearcinfo );
If (licensestatus! = Esrilicensestatus. esrilicensecheckedout)
{
System. Windows. Forms. MessageBox. Show (licensemessage (licensestatus ));
Binitialized = false;
}
}
}
}
Return binitialized;
}
Public void shutdownapplication ()
{
If (m_aoinitialize = NULL) return;
// Close the aoinitilaize object
M_aoinitialize.shutdown ();
M_aoinitialize = NULL;
}
Private esrilicensestatus checkoutlicenses (esrilicenseproductcode productcode)
{
Esrilicensestatus licensestatus;
// Whether the product is possible
Licensestatus = m_aoinitialize.isproductcodeavailable (productcode );
If (licensestatus = esrilicensestatus. esrilicenseavailable)
{
// Use the corresponding license file for initialization
Licensestatus = m_aoinitialize.initialize (productcode );
}
Return licensestatus;
}
Private string licensemessage (esrilicensestatus licensestatus)
{
String message = "";
// No license
If (licensestatus = esrilicensestatus. esrilicensenotinitialized)
{< br> message = "You are not licensed to run this product! ";
}< br> // license in use
else if (licensestatus = esrilicensestatus. esrilicenseunavailable)
{< br> message = "there are insuffient licenses to run! ";
}< br> // unknown error
else if (licensestatus = esrilicensestatus. esrilicensefailure)
{< br> message =" unexpected license failure! Please contact your administrator. ";
}< br> // It has been initialized.
else if (licensestatus = esrilicensestatus. esrilicensealreadyinitialized)
{< br> message = "the license has already been initialized! Please check your implementation. ";
}< br> return message;
}< BR >}