AnsweredAssumed Answered

Can't open FGDB in console application

Question asked by jmundt@CO.WELD.CO.US_weldgov on Jul 29, 2013
Latest reply on Jul 29, 2013 by jmundt@CO.WELD.CO.US_weldgov
Hi, Getting back on the horse after a couple of years in a non-technical position. I am trying to write a console application that iterates through a fc in a FGDB and updates values. Having trouble opening the FGDB. The code below binds, checks out, and verifies that I have checked out a desktop advanced license, but fails on the very last line, opening the FGDB (the first objects command).

Win7, 10.1 Desktop, c# Visual Studio Express 2010
Error: Error HRESULT E_FAIL has been returned from a call to a COM component (no details)
Console says license checkout was successful

thanks in advance


static void OpenFGDB()
{

//get and verify the license
ESRI.ArcGIS.esriSystem.AoInitialize aoInit = null;
try
{
ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.Desktop);
aoInit = new AoInitializeClass();
if (aoInit.IsProductCodeAvailable(esriLicenseProductCode.esriLicenseProductCodeAdvanced) == esriLicenseStatus.esriLicenseAvailable)
{
esriLicenseStatus licStatus = aoInit.Initialize(esriLicenseProductCode.esriLicenseProductCodeAdvanced);
if (licStatus == esriLicenseStatus.esriLicenseCheckedOut)
{
Console.WriteLine("ArcGIS Advnaced License Checkout Successful.");
}
else
{
Console.WriteLine("ArcGIS Advanced License is availble but could not be checked out, program exiting.");
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
Environment.Exit(0);
}
}
else
{
Console.WriteLine("ArcGIS Advanced License not available, program exiting.");
Console.WriteLine("Press any key to exit.");
Console.ReadKey();
Environment.Exit(0);
}
}
catch (Exception exc)
{
Console.WriteLine(exc.Message);
}


//open the fgdb
IWorkspaceFactory pWorkspaceFactory = new FileGDBWorkspaceFactory();
IWorkspace pWorkspace = pWorkspaceFactory.OpenFromFile("@C:\temp\test.gdb", 0); //fails here

}

Outcomes