Issue while using "FileGDBWorkspaceFactory"

1514
1
12-23-2016 05:39 AM
SravaniTirumareddi
New Contributor

IWorkspaceFactory factory= new FileGDBWorkspaceFactory();
IWorkspace workspace= factory.OpenFromFile(path, 0);

The above code causes throws the below error. "Error HRESULT E_FAIL has been returned from a call to a COM component."

Tried the below too. But it didn't work.

Type factoryType=Type.GetTypeFromProgID(         "esriDataSourcesGDB.FileGDBWorkspaceFactory");     IWorkspaceFactory workspaceFactory=(IWorkspaceFactory)Activator.CreateInstance         (factoryType);
IWorkspace workspace=workspaceFactory.OpenFromFile(path, 0);

I have following software installed, 

ArcGis 10.2.1

C# (.Net 4.5)

Please suggest the fix.

0 Kudos
1 Reply
JoshuaBixby
MVP Esteemed Contributor

Not to ask the obvious, are the filename and hWnd you are passing both valid/correct?  What specifically are you passing as path?

Also, have you checked out the following HRESULT E_FAIL threads on GeoNet:

It seems network-path data and illegal characters can cause the error in certain situations.  Also, sometimes it isn't directly related to the code but corrupted caches in Visual Studio, so you might want to Google around for solutions beyond ArcGIS code changes.