I am trying to get back a list of ObjectIDs from a selection set using VB.Net in ArcObjects for ArcGIS Desktop 9.3. I have been passing an object populated using the ".IDs" method from the ISelectionSet interface ((which returns an IEnum2 object with the OBJECTIDS for the selected features) to the following function:
Public Function iterateOIDS(ByRef OID_Enumerator As ESRI.ArcGIS.Geodatabase.IEnumIDs) Dim itemID As = OID_Enumerator.Next() Dim listofOIDS As List(Of Integer) Do While itemID <> -1 listofOIDS.Add(itemID) itemID = OID_Enumerator.Next() Loop Return listofOIDS End Function
However, this crashes ArcGIS and results in Visual Studio throwing an LoaderLock error, if its in Debug Mode. The offending piece of code is apparently the "listofOIDs.Add(itemID)" inside the While Loop.
What am I doing wrong? Any light that anyone can shed on this problem would be awesome!