AnsweredAssumed Answered

Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Geodatabase.ISubtypes'

Question asked by yellow_rose on Jul 31, 2015
Latest reply on Nov 2, 2015 by SEria-esristaff

I am trying to get the subtypes of a feature class that has subtypes but i get this error

"

Unable to cast COM object of type 'System.__ComObject' to interface type 'ESRI.ArcGIS.Geodatabase.ISubtypes'. This

 

 

operation failed because the QueryInterface call on the COM component for the interface with IID '{AEF78514-848F-11D2-

 

 

AABA-00C04FA37B82}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002

 

 

(E_NOINTERFACE))

"

 

at this line :ESRI.ArcGIS.Geodatabase.ISubtypes subtypes = (ESRI.ArcGIS.Geodatabase.ISubtypes)sourceFeatureClass;

 

Here is the code:

protected override List<String> GetDistinctGroupFieldValues(MigrationFeatureClassSource source)

        {

            if (source.SourceName == "Mekka")

            {

                try

                {

                    List<String> distinctValues = null;

                    ESRI.ArcGIS.Geodatabase.IFeatureClass sourceFeatureClass =

 

 

source.DataSource.GetFeatureWorkSpaceOfDataSource().OpenFeatureClass(source.SourceTableName);

                 

                    ESRI.ArcGIS.Geodatabase.ISubtypes subtypes = (ESRI.ArcGIS.Geodatabase.ISubtypes)sourceFeatureClass;

                  

                        ESRI.ArcGIS.Geodatabase.IEnumSubtype enumSubtype;

                        int subtypeCode;

                        string subtypeName;

                        if (subtypes.HasSubtype)

                        {

                            distinctValues = new List<String>();

                            enumSubtype = subtypes.Subtypes;

                            subtypeName = enumSubtype.Next(out subtypeCode);

                            while (subtypeName != null)

                            {

 

 

                                subtypeName = enumSubtype.Next(out subtypeCode);

                                if (subtypeName.Contains("???"))

                                {

                                    distinctValues.Add(subtypeCode.ToString());

                                }

                            }

                        }

                  return distinctValues ;

                   

                }

                catch (Exception ex)

                {

                    Logger.LoggerInstance.LogError(ex.Message, DateTime.Now, "GetDistinctGroupFieldValues",

 

 

"MigrationFeatureClass", m_tableName);

                    throw new Exception(ex.Message);

                }

              

            }

            else

            {

              return base.GetDistinctGroupFieldValues(source);

            }

        }

Outcomes