chris.bennett.gf

Workspace Factory COMException 0x80040228

Discussion created by chris.bennett.gf on Sep 5, 2011
Latest reply on Sep 6, 2011 by chris.bennett.gf
I've seen so many previous posts....  Tried all the things I could find, but still get this stubborn error when I try to instantiate a workspace from a file spec.

Environment:
Windows 7, sp 1
Intel i7, 8Gb RAM
Visual Studio 2010, sp 1
Arc version: 10.0.2414
.NET build target: 3.5


I have a very simple example console program to test opening a simple shape file.  (I'm actually trying to get a file gdb workspace opened, but that fails as well, so does personal gdb.)

All the other posts I've seen have been resolved by one or the other things I've added into the following code, so I'm turning to the real experts :)

using System;
using System.Text;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.esriSystem;

namespace EngineProj
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            string gdbName = @"C:\Projects\test\lines.shp";
            IWorkspace workspace = null;

            ESRI.ArcGIS.RuntimeManager.Bind(ESRI.ArcGIS.ProductCode.EngineOrDesktop);

            IAoInitialize ao = new AoInitializeClass();

            ao.Initialize(esriLicenseProductCode.esriLicenseProductCodeArcEditor);

            Type factoryType = Type.GetTypeFromProgID("esriDataSourcesFile.ShapefileWorkspaceFactory");
            IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(factoryType);

            // This line fails with COMException: Exception from HRESULT: 0x80040228
            workspace = workspaceFactory.OpenFromFile(gdbName, 0);
        }
    }
}


Any hints are most appreciated.

Thanks!

-Chris.

Outcomes