I am writing an application that needs to run through a GDB with one dataset and multiple feature classes. The feature classes have subtypes and coded domain values. I need to get the count by subtype. Every time I run this code in my application it crashes when it gets to "IDataElement dataElem = (IDataElement)gp2.GetDataElement(fcPath, ref dType);". It does not throw an exception it just terminates the application completely.
The odd thing is that if I extract this code from the application it will run by itself. Anyone have any ideas at all? I'm desperate and I need to figure this out.
The odd thing is that if I extract this code from the application it will run by itself. Anyone have any ideas at all? I'm desperate and I need to figure this out.
Code:
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();
}