[GIS] ArcObjects .NET – Initializing License

arcobjectsasp.net

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.

Best Answer

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);
}
Related Question