Would anyone know the reason why this happens? and possibly a way to fix it. I am stumped
In the following code. The first addlayer works, but crashes on the second addlayer with a 'vshost32.exe has stopped working' error.
However when I comment out all the addlayers and make it to the for loop. All three addlayers display correctly.
Why would the exact same code work in a for loop, but not when add a second, third and fourth layer individually.
Any ideas?
ThanksDerek
// want to open shapefilepFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass("wa_body_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer");pFeatureLayer.FeatureClass = pFeatureClass;pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass;pFeatureLayer.Name = pDataset.Name;pMap.AddLayer(pFeatureLayer);pFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass(QCForm.chkLstNSHNPolygons.Items[8].ToString()); // "wa_poly_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer");pFeatureLayer.FeatureClass = pFeatureClass;pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass;pFeatureLayer.Name = pDataset.Name;pMap.AddLayer(pFeatureLayer);pFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass(QCForm.chkLstNSHNLines.Items[4].ToString());// "nshn_line_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer");pFeatureLayer.FeatureClass = pFeatureClass;pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass;pFeatureLayer.Name = pDataset.Name;pMap.AddLayer(pFeatureLayer);pFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass(QCForm.chkLstNSHNPoints.Items[5].ToString()); // "nshn_point_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer");pFeatureLayer.FeatureClass = pFeatureClass;pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass;pFeatureLayer.Name = pDataset.Name;pMap.AddLayer(pFeatureLayer);pFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass(QCForm.chkLstNSHNJunctions.Items[4].ToString()); // "nshn_junc_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer"); pFeatureLayer.FeatureClass = pFeatureClass; pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass; pFeatureLayer.Name = pDataset.Name; pMap.AddLayer(pFeatureLayer); //Add topology layers i = 0; for (i = 0; i
In the following code. The first addlayer works, but crashes on the second addlayer with a 'vshost32.exe has stopped working' error.
However when I comment out all the addlayers and make it to the for loop. All three addlayers display correctly.
Why would the exact same code work in a for loop, but not when add a second, third and fourth layer individually.
Any ideas?
ThanksDerek
// want to open shapefilepFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass("wa_body_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer");pFeatureLayer.FeatureClass = pFeatureClass;pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass;pFeatureLayer.Name = pDataset.Name;pMap.AddLayer(pFeatureLayer);pFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass(QCForm.chkLstNSHNPolygons.Items[8].ToString()); // "wa_poly_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer");pFeatureLayer.FeatureClass = pFeatureClass;pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass;pFeatureLayer.Name = pDataset.Name;pMap.AddLayer(pFeatureLayer);pFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass(QCForm.chkLstNSHNLines.Items[4].ToString());// "nshn_line_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer");pFeatureLayer.FeatureClass = pFeatureClass;pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass;pFeatureLayer.Name = pDataset.Name;pMap.AddLayer(pFeatureLayer);pFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass(QCForm.chkLstNSHNPoints.Items[5].ToString()); // "nshn_point_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer");pFeatureLayer.FeatureClass = pFeatureClass;pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass;pFeatureLayer.Name = pDataset.Name;pMap.AddLayer(pFeatureLayer);pFeatureClass = pLocalFeatureWorkspace.OpenFeatureClass(QCForm.chkLstNSHNJunctions.Items[4].ToString()); // "nshn_junc_" + sGeoname);pFeatureLayer = (ESRI.ArcGIS.Carto.IFeatureLayer)pObjectFactory.Create("esriCarto.FeatureLayer"); pFeatureLayer.FeatureClass = pFeatureClass; pDataset = (ESRI.ArcGIS.Geodatabase.IDataset)pFeatureClass; pFeatureLayer.Name = pDataset.Name; pMap.AddLayer(pFeatureLayer); //Add topology layers i = 0; for (i = 0; i