Is This Content Helpful?
We're glad to know this article was helpful.
Starting in ArcGIS 9.2, when a given selection is changed, multiple events are raised: two when clearing the current selection, and one more when the new selection is made.
Because of this, any functions written by a developer for handling the change in selection may try to access the selection set before it is assigned the value of the new selection. If this occurs, an error results.
This behavior is by design.
To prevent the error, check to be sure the selection set is not null before accessing it in an event handler. ArcObjects developers should always check to be sure that a variable is initialized before reading or writing to it. An example from the VB6 SDK help for ISelectionEvents is shown below:
[Visual Basic 6.0]
' Respond to selection events
Private Sub m_pSelectionEvents_SelectionChanged()
If m_pMap Is Nothing Then Exit Sub ' no map exit...
If m_pMap.SelectionCount = 0 Then Exit Sub ' no selection nothing to do...
MsgBox m_pMap.SelectionCount & " feature(s) are selected."
Because this behavior is different from ArcGIS 9.1, developers may need to revise and/or recompile older customizations to reflect this change.