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