For those unfortunate enough to have to code in VB .NET (my fate!), I have translated Daniel's clean C# code in to good ol' crummy VB:
<Autodesk.AutoCAD.Runtime.CommandMethod("test")> _
Public Sub test()
Dim values As TypedValue() = New TypedValue() { _
New TypedValue(CType(DxfCode.Start, Short), "INSERT"), _
New TypedValue(CType(DxfCode.XDataStart, Short)), _
New TypedValue(CType(DxfCode.ExtendedDataRegAppName, Short), "MYAPPNAME") _
}
Dim filter As SelectionFilter = New SelectionFilter(values)
Dim selopts As PromptSelectionOptions = New PromptSelectionOptions()
Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
selopts.MessageForAdding = "Select"
selopts.AllowDuplicates = False
Dim result As PromptSelectionResult = ed.GetSelection(selopts, filter)
If (result.Status = PromptStatus.OK) Then
Dim idarray As ObjectId() = result.Value.GetObjectIds()
Dim tm As Autodesk.AutoCAD.DatabaseServices.TransactionManager = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager
Dim tr As Transaction = tm.StartTransaction()
Try
For Each id1 As ObjectId In idarray
Dim entity1 As Entity = CType(tm.GetObject(id1, OpenMode.ForRead, True), Entity)
ed.WriteMessage("\nYou selected: " + entity1.GetType().FullName)
Next
Finally
tr.Dispose()
End Try
End If
End Sub