imuepis

Exception from HRESULT: 0x8004150D

Discussion created by imuepis on Feb 7, 2011
Latest reply on Feb 7, 2011 by ebrimhall
Hi,
For some time I`m keep getting an ugly error from ArcObjects 10 that I can not figure out. From my point of view the code below does not have anything wrong with it:
IWorkspaceFactory2 workspaceFactory = new SdeWorkspaceFactory() as IWorkspaceFactory2;
            IWorkspace workspace = workspaceFactory.OpenFromString("connection to sql server", 0);
            IFeatureClass featureClass0 = ((IFeatureWorkspace)workspace).OpenFeatureClass("TABLE0");
            IFeatureClass featureClass1 = ((IFeatureWorkspace)workspace).OpenFeatureClass("TABLE1");
            IFeatureClass featureClass2 = ((IFeatureWorkspace)workspace).OpenFeatureClass("TABLE2");
            IQueryFilter2 filter = new QueryFilterClass();
            ISpatialFilter geometryFilter = new SpatialFilterClass();
            IFeature selectedStateForest = null;

            filter.WhereClause = "mu_kod = 11";

            selectedStateForest = featureClass0.Search(filter, true).NextFeature();

            geometryFilter.Geometry = selectedStateForest.Shape;
            geometryFilter.SpatialRel = esriSpatialRelEnum.esriSpatialRelContains;

            try
            {
                do
                {
                    IFeatureCursor iter = featureClass1.Search(geometryFilter, true);
                    IFeature tmp = null;
                    int count1 = -1, count2 = -1;

                    do
                    {
                        tmp = iter.NextFeature();

                        count1++;
                    } while (tmp != null);

                    iter = featureClass2.Search(geometryFilter, true);
                    do
                    {
                        tmp = iter.NextFeature();

                        count2++;
                    } while (tmp != null);
                } while (true);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Whoops");
            }

In this example I`m doing simple counting for error reproduction. It seems that sometimes error is like in post title and sometimes it`s just HRESULT E_FAIL. Application runs for about minute returning correct results and then simply fails. Any help would be appreciated.

Outcomes