GeoProcessor gp = new GeoProcessor(); IWorkspaceFactory wsFact = new FileGDBWorkspaceFactoryClass(); IWorkspace ws = wsFact.OpenFromFile(destData, 0); IEnumDataset enumDS = ws.get_Datasets(esriDatasetType.esriDTFeatureDataset); IFeatureDataset ltdsDS = (IFeatureDataset)enumDS.Next(); IEnumDataset enumFC = ltdsDS.Subsets; IDataset currFC = enumFC.Next(); fCodeCounts = new Dictionary<string, Dictionary<int, int>>(); while (currFC != null) { FeatureClass fc = (FeatureClass)currFC; IFeatureClass fcl = (IFeatureClass)fc; System.Object dType = ""; string fcPath = destData + "\\" + ltdsDS.BrowseName + "\\" + fc.BrowseName; IDataElement dataElem = (IDataElement)gp.GetDataElement(fcPath, ref dType); IDEGdbTable deTbl = (IDEGdbTable)dataElem; IArray arr = deTbl.Subtypes; Dictionary<int, int> tempDict = new Dictionary<int, int>(); fCodeCounts.Add(fc.BrowseName, new Dictionary<int,int>()); for (int i = 0; i < (arr.Count); i++) { IGPSubtype gpSt = (IGPSubtype)arr.get_Element(i); tempDict.Add(gpSt.SubtypeCode, fcl.FeatureCount(CreateSubtypeQuery(gpSt.SubtypeCode))); } fCodeCounts.Add(fc.BrowseName, tempDict); currFC = enumFC.Next(); }
Solved! Go to Solution.
while (currFC != null) { FeatureClass fc = (FeatureClass)currFC; IFeatureClass fcl = (IFeatureClass)fc; ISubtypes subtypes = (ISubtypes)fcl; IEnumSubtype enumSubtype; int subtypeCode; string subtypeName; Dictionary<int, int> tempDict; if (subtypes.HasSubtype) { enumSubtype = subtypes.Subtypes; subtypeName = enumSubtype.Next(out subtypeCode); tempDict = new Dictionary<int, int>(); while (subtypeName != null) { tempDict.Add(subtypeCode, fcl.FeatureCount(CreateSubtypeQuery(subtypeCode))); subtypeName = enumSubtype.Next(out subtypeCode); } fCodeCounts.Add(fc.BrowseName, tempDict); } currFC = enumFC.Next();
while (currFC != null) { FeatureClass fc = (FeatureClass)currFC; IFeatureClass fcl = (IFeatureClass)fc; ISubtypes subtypes = (ISubtypes)fcl; IEnumSubtype enumSubtype; int subtypeCode; string subtypeName; Dictionary<int, int> tempDict; if (subtypes.HasSubtype) { enumSubtype = subtypes.Subtypes; subtypeName = enumSubtype.Next(out subtypeCode); tempDict = new Dictionary<int, int>(); while (subtypeName != null) { tempDict.Add(subtypeCode, fcl.FeatureCount(CreateSubtypeQuery(subtypeCode))); subtypeName = enumSubtype.Next(out subtypeCode); } fCodeCounts.Add(fc.BrowseName, tempDict); } currFC = enumFC.Next();
In ArcGIS 10.4.1 we had a similar issue and we fixed the problem changing the property value "Embeded Interop types" to True from the reference library Esri.ArcGIS.GeoProcessor:
Embeded Interop types: True.