2

I'm brand new to ArcObjects. I've got it installed, and now I want to try using it in a .NET MVC application. In the controller, I think I need to initialize the license before I can do anything with ArcObjects since this is a standalone web application. Is there a code snippet out there to do that? I've been reading various threads and I'm having trouble putting it together. I'm using 10.5

I know at some point I have to call this:

ESRI.ArcGIS.RuntimeManager.BindLicense(ProductCode.Desktop)

but there's also some other code about initialization (AoInitialize ?) that I'm not sure where to put or what to do with.

1
  • If you create your solution using the ArcGIS templates installed with the SDK the AoInitialize is done for you using the product and extension level indicated at startup.. you do have the SDK for ArcGIS installed don't you? If not it's a really good idea to install it before you start creating any .net code using ArcObjects. Oct 23, 2017 at 23:21

1 Answer 1

6

This should do what you're looking for, but mind you may need to change the esriLicenseProductCode enum to something else depending on your license.

private void licenseCheck()
{
     ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
     ESRI.ArcGIS.esriSystem.IAoInitialize ao = new ESRI.ArcGIS.esriSystem.AoInitialize();
     ao.Initialize(ESRI.ArcGIS.esriSystem.esriLicenseProductCode.esriLicenseProductCodeAdvanced);
}
3
  • 2
    You place this code BEFORE any call to any ArcObjects, typically in some function that is called on start up.
    – Hornbydd
    Oct 23, 2017 at 15:02
  • @danielm Is there a difference between Bind and BindLicense? Thanks for the help!
    – MKF
    Oct 23, 2017 at 15:36
  • 1
    @Stuff BindLicense looks like it is a shortcut for Bind in some instances: help.arcgis.com/en/sdk/10.0/arcobjects_net/componenthelp/…
    – danielm
    Oct 23, 2017 at 15:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.