COM Exception was unhandled HRESULT: 0x80040351 while moving data

4299
2
06-03-2010 11:51 AM
PareshVaratkar
New Contributor
Hi,
I am trying to move data from GIS server 9.3 to personal Geodatabase mdb file.
Attached is the code copied from http://edndoc.esri.com/arcobjects/9.2/NET/91E3E8A0-D355-43D2-A201-0A8CEB719334.htm#CodeExample
I am getting the exception while opening the Feature Class
  sourceFeatureClass = (IFeatureClass)sourceName.Open();    
COM Exception was unhandled HRESULT: 0x80040351
I have attached the complete stack trace below.
The table has at the most 300 rows.
Not sure whats causing the issue. I have already wasted couple of days.
Please help.
Regards
Paresh

private void button1_Click(object sender, EventArgs e)
        {
            ESRI.ArcGIS.esriSystem.IPropertySet propertySet = new ESRI.ArcGIS.esriSystem.PropertySetClass();

            propertySet.SetProperty("SERVER", "cirus");
            propertySet.SetProperty("INSTANCE", "esri_sde_prod");
            propertySet.SetProperty("USER", "scott");
            propertySet.SetProperty("PASSWORD", "tiger");
            propertySet.SetProperty("VERSION", "SDE.DEFAULT");
            propertySet.SetProperty("AUTHENTICATION_MODE", "DBMS");
        
            IWorkspaceFactory sourceWorkspaceFactory = new ESRI.ArcGIS.DataSourcesGDB.SdeWorkspaceFactoryClass();
            IWorkspace sourceWorkspace = sourceWorkspaceFactory.Open(propertySet, 0);
            // Create new workspace name objects.


              // Open the source and target workspaces.
            //String sourceWorkspacePath = @"C:\arcgis\ArcTutor\ArcReader and Publisher\Data";
            String targetWorkspacePath = "C:\\VSS\\Projects\\Marshall\\Person Geo Database\\water.mdb";
            //IWorkspaceFactory sourceWorkspaceFactory = new ShapefileWorkspaceFactoryClass();
            IWorkspaceFactory targetWorkspaceFactory = new AccessWorkspaceFactoryClass();
            //IWorkspace sourceWorkspace = sourceWorkspaceFactory.OpenFromFile(sourceWorkspacePath, 0);
            IWorkspace targetWorkspace = targetWorkspaceFactory.OpenFromFile
            (targetWorkspacePath, 0);

            // Cast the workspaces to the IDataset interface and get name objects.
            IDataset sourceWorkspaceDataset = (IDataset)sourceWorkspace;
            IDataset targetWorkspaceDataset = (IDataset)targetWorkspace;
            IName sourceWorkspaceDatasetName = sourceWorkspaceDataset.FullName;
            IName targetWorkspaceDatasetName = targetWorkspaceDataset.FullName;
            IWorkspaceName sourceWorkspaceName = (IWorkspaceName)
            sourceWorkspaceDatasetName;
            IWorkspaceName targetWorkspaceName = (IWorkspaceName)
            targetWorkspaceDatasetName;

            // Create a name object for the shapefile and cast it to the IDatasetName interface.
            IFeatureClassName sourceFeatureClassName = new FeatureClassNameClass();
            IDatasetName sourceDatasetName = (IDatasetName)sourceFeatureClassName;
            sourceDatasetName.Name = "SRV_METER_X";
            sourceDatasetName.WorkspaceName = sourceWorkspaceName;

            // Open source feature class to get field definitions.
            IName sourceName = (IName)sourceFeatureClassName;
            IFeatureClass sourceFeatureClass;
            sourceFeatureClass = (IFeatureClass)sourceName.Open();       


            // Create a name object for the FGDB feature class and cast it to the IDatasetName interface.
            IFeatureClassName targetFeatureClassName = new FeatureClassNameClass();
            IDatasetName targetDatasetName = (IDatasetName)targetFeatureClassName;
            targetDatasetName.Name = "SRV_METER_X";
            targetDatasetName.WorkspaceName = targetWorkspaceName;


            // Create the objects and references necessary for field validation.
            IFieldChecker fieldChecker = new FieldCheckerClass();
            IFields sourceFields = sourceFeatureClass.Fields;
            IFields targetFields = null;
            IEnumFieldError enumFieldError = null;

            // Set the required properties for the IFieldChecker interface.
            fieldChecker.InputWorkspace = sourceWorkspace;
            fieldChecker.ValidateWorkspace = targetWorkspace;

            // Validate the fields and check for errors.
            fieldChecker.Validate(sourceFields, out enumFieldError, out targetFields);
            if (enumFieldError != null)
            {
                // Handle the errors in a way appropriate to your application.
                Console.WriteLine("Errors were encountered during field validation.");
            }

            // Find the shape field.
            String shapeFieldName = sourceFeatureClass.ShapeFieldName;
            int shapeFieldIndex = sourceFeatureClass.FindField(shapeFieldName);
            IField shapeField = sourceFields.get_Field(shapeFieldIndex);

            // Get the geometry definition from the shape field and clone it.
            IGeometryDef geometryDef = shapeField.GeometryDef;
            IClone geometryDefClone = (IClone)geometryDef;
            IClone targetGeometryDefClone = geometryDefClone.Clone();
            IGeometryDef targetGeometryDef = (IGeometryDef)targetGeometryDefClone;

            // Cast the IGeometryDef to the IGeometryDefEdit interface.
            IGeometryDefEdit targetGeometryDefEdit = (IGeometryDefEdit)targetGeometryDef;

            // Set the IGeometryDefEdit properties.
            targetGeometryDefEdit.GridCount_2 = 1;
            targetGeometryDefEdit.set_GridSize(0, 0.75);

            // Create a query filter to only select cities with a province (PROV) value of 'NS'.
            IQueryFilter queryFilter = new QueryFilterClass();
            queryFilter.WhereClause = "INSPECTR LIKE 'UTM%'";
            queryFilter.SubFields = "*";

            // Create the converter and run the conversion.
            IFeatureDataConverter featureDataConverter = new FeatureDataConverterClass();
            IEnumInvalidObject enumInvalidObject =
            featureDataConverter.ConvertFeatureClass(sourceFeatureClassName,
            queryFilter, null, targetFeatureClassName, targetGeometryDef, targetFields,
            "", 1000, 0);

            // Check for errors.
            IInvalidObjectInfo invalidObjectInfo = null;
            enumInvalidObject.Reset();
            while ((invalidObjectInfo = enumInvalidObject.Next()) != null)
            {
                // Handle the errors in a way appropriate to the application.
                Console.WriteLine("Errors occurred for the following feature: {0}",
                  invalidObjectInfo.InvalidObjectID);
            }



        }

at ESRI.ArcGIS.Geodatabase.FeatureClassNameClass.Open()   at GisApp.Form1.button1_Click(Object sender, EventArgs e) in C:\\VSS\\Projects\\GIS\\GisApp\\Form1.cs:line 73   at System.Windows.Forms.Control.OnClick(EventArgs e)   at System.Windows.Forms.Button.OnClick(EventArgs e)   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)   at System.Windows.Forms.Control.WndProc(Message& m)   at System.Windows.Forms.ButtonBase.WndProc(Message& m)   at System.Windows.Forms.Button.WndProc(Message& m)   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)   at System.Windows.Forms.Application.Run(Form mainForm)   at GisApp.Program.Main() in C:\\VSS\\Projects\\GIS\\GisApp\\Program.cs:line 22   at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)   at System.Threading.ThreadHelper.ThreadStart()
0 Kudos
2 Replies
RemigijusPankevicius
New Contributor
Don't waste time, check 0x80040351 at http://0x80004005.appspot.com/, it says FDO_E_TABLE_NOT_FOUND
0 Kudos
NesimiAliyev
New Contributor

Spatial Analyst ISurfaceOp2 Contour method error 80040351. How to fix?

 

0 Kudos