Skip to main content
Improved formatting and grammar.
Source Link
Hornbydd
  • 44.6k
  • 5
  • 42
  • 84

Error when i useusing IFeatureCursor to inquire feature,there is a error

enter image description hereVisual Studio

ASAs you cancan see the other attributes isare doing well,but but the shape of the feature throw an exception "Shape = "(pFeature).Shape" raises an exception of type "System.Runtime.InteropServices.COMException"" WHY. Why?

 a = axMapControl1.get_Layer(j) as ICompositeLayer;

                    pfl = a.get_Layer(0) as IFeatureLayer;
                    IFeatureClass pfeatureclass = pfl.FeatureClass;
                    if (pfl != null)
                    {
                        IQueryFilter queryFilter = new QueryFilterClass
                        {
                            SubFields = "Id",
                            WhereClause = "Id = " + pointid
                        };

                        pFeatureSelection = pfl as IFeatureSelection;
                        pFeatureSelection.Clear();
                        pFeatureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, true);
                        pSelectionSet = pFeatureSelection.SelectionSet;
                        IFeatureCursor pFeatureCursor = pfl.Search(queryFilter, true);          
                        IFeature pFeature;

                        pFeature = pFeatureCursor.NextFeature();   
 a = axMapControl1.get_Layer(j) as ICompositeLayer;

 pfl = a.get_Layer(0) as IFeatureLayer;
 IFeatureClass pfeatureclass = pfl.FeatureClass;
 if (pfl != null)
 {
 IQueryFilter queryFilter = new QueryFilterClass
 {
  SubFields = "Id",
  WhereClause = "Id = " + pointid
 };

 pFeatureSelection = pfl as IFeatureSelection;
 pFeatureSelection.Clear();
 pFeatureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, true);
 pSelectionSet = pFeatureSelection.SelectionSet;
 IFeatureCursor pFeatureCursor = pfl.Search(queryFilter, true);          
 IFeature pFeature;
 pFeature = pFeatureCursor.NextFeature();   

when i use IFeatureCursor to inquire feature,there is a error

enter image description here

AS you can see the other attributes is doing well,but the shape of the feature throw an exception "Shape = "(pFeature).Shape" raises an exception of type "System.Runtime.InteropServices.COMException"" WHY?

 a = axMapControl1.get_Layer(j) as ICompositeLayer;

                    pfl = a.get_Layer(0) as IFeatureLayer;
                    IFeatureClass pfeatureclass = pfl.FeatureClass;
                    if (pfl != null)
                    {
                        IQueryFilter queryFilter = new QueryFilterClass
                        {
                            SubFields = "Id",
                            WhereClause = "Id = " + pointid
                        };

                        pFeatureSelection = pfl as IFeatureSelection;
                        pFeatureSelection.Clear();
                        pFeatureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, true);
                        pSelectionSet = pFeatureSelection.SelectionSet;
                        IFeatureCursor pFeatureCursor = pfl.Search(queryFilter, true);          
                        IFeature pFeature;

                        pFeature = pFeatureCursor.NextFeature();   

Error when using IFeatureCursor to inquire feature

Visual Studio

As you can see the other attributes are doing well, but the shape of the feature throw an exception "Shape = "(pFeature).Shape" raises an exception of type "System.Runtime.InteropServices.COMException"". Why?

 a = axMapControl1.get_Layer(j) as ICompositeLayer;

 pfl = a.get_Layer(0) as IFeatureLayer;
 IFeatureClass pfeatureclass = pfl.FeatureClass;
 if (pfl != null)
 {
 IQueryFilter queryFilter = new QueryFilterClass
 {
  SubFields = "Id",
  WhereClause = "Id = " + pointid
 };

 pFeatureSelection = pfl as IFeatureSelection;
 pFeatureSelection.Clear();
 pFeatureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, true);
 pSelectionSet = pFeatureSelection.SelectionSet;
 IFeatureCursor pFeatureCursor = pfl.Search(queryFilter, true);          
 IFeature pFeature;
 pFeature = pFeatureCursor.NextFeature();   
Source Link
getti
  • 13
  • 2

when i use IFeatureCursor to inquire feature,there is a error

enter image description here

AS you can see the other attributes is doing well,but the shape of the feature throw an exception "Shape = "(pFeature).Shape" raises an exception of type "System.Runtime.InteropServices.COMException"" WHY?

 a = axMapControl1.get_Layer(j) as ICompositeLayer;

                    pfl = a.get_Layer(0) as IFeatureLayer;
                    IFeatureClass pfeatureclass = pfl.FeatureClass;
                    if (pfl != null)
                    {
                        IQueryFilter queryFilter = new QueryFilterClass
                        {
                            SubFields = "Id",
                            WhereClause = "Id = " + pointid
                        };

                        pFeatureSelection = pfl as IFeatureSelection;
                        pFeatureSelection.Clear();
                        pFeatureSelection.SelectFeatures(queryFilter, esriSelectionResultEnum.esriSelectionResultNew, true);
                        pSelectionSet = pFeatureSelection.SelectionSet;
                        IFeatureCursor pFeatureCursor = pfl.Search(queryFilter, true);          
                        IFeature pFeature;

                        pFeature = pFeatureCursor.NextFeature();