I am building a tool in my Add-in that is partially based on a .Net sample and partially on my former VBA tool. (Both work)
My problem is that I would like to be able to only select features from the current layer in the TOC. For this i have to use iFeatureSelection:SelectFeatures with iSpatialFilter. This works flawlessly in VBA but not in my .Net Add-in
ArcMap crashes when I refresh / partial refresh the map.
pGeoFeatureLayer.Selectable = True pFeatureSelection = pGeoFeatureLayer pEnv = m_pFeedbackEnv.Stop() With pSpatialFilter .GeometryField = "Shape" .Geometry = pEnv .SpatialRel = ESRI.ArcGIS.Geodatabase.esriSpatialRelEnum.esriSpatialRelIntersects End With If Not arg.Shift Then pFeatureSelection.SelectFeatures(pSpatialFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultNew, False) Else pFeatureSelection.SelectFeatures(pSpatialFilter, ESRI.ArcGIS.Carto.esriSelectionResultEnum.esriSelectionResultAdd, False) End If m_focusMap.PartialRefresh(ESRI.ArcGIS.Carto.esriViewDrawPhase.esriViewGeoSelection, Nothing, Nothing)