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 occurredMessage="ArcGIS version not specified. You must first bind to an ArcGIS version prior to using any ArcGIS components."Source="esriSystem.AoInitialize"ErrorCode=-2147221002StackTrace: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: EngineVersion: "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.