18.04.2015 Views

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

ArcGIS Engine Developer Guide

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

BUILDING APPLICATIONS WITH WINDOWS CONTROLS<br />

When developing a standalone executable using<br />

ArcObjects, it is the responsibility of the application<br />

to check and configure the licensing options.<br />

A license can be configured, using either the<br />

LicenseControl or the coclass AoInitialize and<br />

the IAoInitialize interface it implements, that is<br />

designed to support license configuration. License<br />

initialization must be performed at application<br />

start time, before any ArcObjects functionality is<br />

accessed. Failure to do so will result in application<br />

errors. For more information about licensing<br />

see Chapter 5, ‘Licensing and deployment’.<br />

The LicenseControl will appear on a form at<br />

design time so that it can be selected and its<br />

property pages viewed. However, at runtime the<br />

LicenseControl is invisible so its position on the<br />

form is irrelevant.<br />

LICENSE CONFIGURATION AND DEPLOYMENT<br />

To successfully deploy this application onto another machine, the application<br />

must configure a license. First, it must check that the product license is available,<br />

and second, it must initialize the license. If this license configuration fails, the<br />

application cannot run. License configuration can be performed either using the<br />

LicenseControl or programmatically using the AoInitialize object. For the purpose<br />

of this application, the LicenseControl will be used to handle license configuration.<br />

1. Open the .Net form in design mode.<br />

2. Double-click the AxLicenseControl in the Windows Forms tab of the toolbox<br />

to add a LicenseControl onto the form.<br />

This application can be initialized with an <strong>ArcGIS</strong><br />

<strong>Engine</strong> license, but you may optionally initialize<br />

the application with a higher product license. For<br />

example, if you check the ‘<strong>ArcGIS</strong> <strong>Engine</strong>’ license<br />

and the ‘ArcView’ license, the LicenseControl will<br />

initially try to initialize the application with an<br />

<strong>ArcGIS</strong> <strong>Engine</strong> license (the lower license). If that<br />

license is not available, the LicenseControl will<br />

try to initialize the application with an ArcView<br />

license (the next higher level license checked). If<br />

no product licenses are available, then the<br />

application will fail to initialize.<br />

In this application the LicenseControl will handle<br />

license initialization failure. If the application<br />

cannot be initialized with an <strong>ArcGIS</strong> <strong>Engine</strong><br />

product license, a License Failure dialog box will<br />

be displayed to the user before the application is<br />

automatically shut down. Alternatively, a<br />

developer can handle license initialization failure<br />

using the ILicenseControl interface members to<br />

obtain information on the nature of the failure<br />

before the application is programmatically shut<br />

down.<br />

3. Right-click on LicenseControl and click Properties to open the LicenseControl<br />

property pages.<br />

4. Check the <strong>ArcGIS</strong> <strong>Engine</strong> product license and check ‘Shutdown this application<br />

if the selected licenses are not available’. Click OK.<br />

5. Select Form1 from the Properties window and display the Form events.<br />

Double-click the Closing event to add an event handler to the code window.<br />

Chapter 6 • <strong>Developer</strong> scenarios • 355

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!