Monday 27 August 2018

AoInitialize - "ArcGIS product not specified." 10.1 Student Edition single use license


I have a Student Edition of ArcGIS 10.1 for Desktop Advanced. My license is set up on my machine as single use. I am trying to initialize the license in ArcObjects, however I get the following error:


"ArcGIS product not specified. You must first bind to an ArcGIS version prior to using any ArcGIS components."


This occurs when I call AoInitialize.IsProductCodeAvailable() which doesn't make sense, since that is how you figure out what license to initialize in the first place. Here is my code:


public static esriLicenseStatus Intialize(

ESRI.ArcGIS.esriSystem.esriLicenseProductCode esriLicenseProductCode)
{
IAoInitialize aoInitialize = new AoInitialize();
esriLicenseStatus esriLicenseStatus =
aoInitialize.IsProductCodeAvailable(esriLicenseProductCode);

if (esriLicenseStatus == ESRI.ArcGIS.esriSystem.esriLicenseStatus.esriLicenseAvailable)
esriLicenseStatus =
aoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);


return esriLicenseStatus;
}

What am I doing wrong? Does this have to do with it being Student Edition?



Answer



Try this code using the RuntimeManager class, makes it much simpler:


    if (ESRI.ArcGIS.RuntimeManager.ActiveRuntime == null)
ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

You'll need to add a reference to the ESRI.ArcGIS.Version assembly.



No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...