"ArcGIS version not specified." (Though it seems to be.)

2695
2
04-23-2010 10:27 AM
patblair
New Contributor
I am having some trouble with the RuntimeManager in the ArcGIS 10.0 beta. I persistently (though not consistently) get an exception at this point in my code:

// Before executing the offending line, I do this to "bind to an ArcGIS version".  
// (In this example I use Engine, but I have the same problem if I use Server).
RuntimeManager.Bind(ProductCode.Engine);
// (These are the variables I'm working with...)
esriLicenseStatus licenseStatus;
private IAoInitialize m_AoInitialize = new AoInitializeClass();
esriLicenseProductCode productCode;
// This line is where I get the exception...
licenseStatus = m_AoInitialize.IsProductCodeAvailable(productCode);


// And here are the exception details...
System.Runtime.InteropServices.COMException occurred
Message="ArcGIS version not specified. You must first bind to an ArcGIS version prior to using any ArcGIS components."
Source="esriSystem.AoInitialize"
ErrorCode=-2147221002
StackTrace:
at ESRI.ArcGIS.esriSystem.AoInitializeClass.IsProduct CodeAvailable(esriLicenseProductCode ProductCode)
at Bbsi.ArcObjects.Bs.AoLicenseInitializer.CheckOutPr oduct(esriLicenseProductCode productCode) in <my code file>
InnerException:

My machine does have valid Engine and Server licenses.

The peculiar part is that I don't see this exception every single time. I happens most of the time; but without my changing anything, it some times does not. I have flailed at it by changing the product code I pass to RuntimeManager.Bind() from Engine to Server, placing breakpoints and waiting a few seconds between calling RuntimeManager.Bind() and calling IsProductCodeAvailable(), but I have yet to determine with certainty how to make it succeed or fail reliably. When the exception is not thrown, the application behaves normally.

If I place a break point before the offending line of code and inspect the RuntimeManager's ActiveRuntime property, it looks as though it's ready to go (so far as I can tell, anyway):

ESRI.ArcGIS.RuntimeManager.ActiveRuntime
{ESRI.ArcGIS.RuntimeInfo}
Path: "C:\\Program Files\\ArcGIS\\Engine10.0\\"
Product: Engine
Version: "10.0"

I am using C# and Visual Studio 2008 on Windows 7 (32-bit) and had no similar problem with this application when I built it against 9.3. In fact, the only difference between the version built against 9.3 and this one is the call to RuntimeManager.Bind(), which I understand is a new convention in 10.0.

I would greatly appreciate any advice I can get.
0 Kudos
2 Replies
patblair
New Contributor
Not too long after I posted this message, I found an explanation for the behavior I described.  I was, indeed, initializing an ArcObjects class as a private member of my class before calling RuntimeManager.Bind().  That initialization didn't throw an exception; but by creating it after calling RuntimeManager.Bind(), I no longer seem to see the problem mentioned in my post.
0 Kudos
Wan_NurAkmal
New Contributor
Not too long after I posted this message, I found an explanation for the behavior I described.  I was, indeed, initializing an ArcObjects class as a private member of my class before calling RuntimeManager.Bind().  That initialization didn't throw an exception; but by creating it after calling RuntimeManager.Bind(), I no longer seem to see the problem mentioned in my post.


hi patbullberry,

eventho this thread was created long time ago, may i know where to call the runtimemanager.bind?

i have the same problem, where this exception occurs when i execute my project. some how, i've called runtimemanager.bind() in my sub form and it was ok. but when i compile the whole project, the exception appeared again in my main form.

really appreciate your feed back 🙂
0 Kudos