Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

This code works fine on my Windows 7 64 bit machine, but fails on the target machine, Windows Server Standard SP2 64 bit.

 public List<string> GetShapeFileFieldNames(string shapeFileDirectory, string shapeFileName)
        shapeFileName = shapeFileName.ToUpper().Replace(".LYR", ".SHP"); 

        IWorkspaceName pInShpWorkspaceName = new WorkspaceNameClass() as IWorkspaceName;
        pInShpWorkspaceName.PathName = shapeFileDirectory;
        pInShpWorkspaceName.WorkspaceFactoryProgID = "esriCore.ShapefileWorkspaceFactory";
        IFeatureClassName pFCName = new FeatureClassNameClass() as IFeatureClassName;
        IDatasetName pShpDatasetName = pFCName as IDatasetName;
        pShpDatasetName.Name = shapeFileName;//this is your input file 
        pShpDatasetName.WorkspaceName = pInShpWorkspaceName;

        IName sourceName = (IName)pFCName;
        IFeatureClass sourceFeatureClass = (IFeatureClass)sourceName.Open(); //HERE IS THE ERROR
        IFields sourceFields = sourceFeatureClass.Fields;
        return GetFieldNames(sourceFields);

Exception from HRESULT 0x80040351 at ESRI.ArcGIS.Geodatabase.FeatureClassNameClass.Open()

I converted the HRESULT into decimal, 2147746641, and ran it through Google

  • 2147746641 ESRI
  • 2147746641 Constants

No results.

share|improve this question
This looks like really old code ... try replacing "esriCore" with "esriDataSourcesFile". The progID's changed way back (at 8.3?). Also shapeFileName doesn't need an extension. – Kirk Kuykendall Jan 4 '12 at 21:13
@Kirk Kuykendall I took the code from the book, "Programming ArcObjects with VBA" I guess its dated. – patrick Jan 5 '12 at 19:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.