AutoCAD 2007 / Autodesk Map 3D 2007
Under certain (rather obscure) circumstances ResultBuffer.ToArray fails, throwing an error. It seems that described glitch happens more often on slower CPUs. Error-free workaround: create generic List(Of TypeValue), then iterate through ResultBuffer using For...Each loop, filling the List collection. When finished iterating, fire List.ToArray to get ResultBuffer's array of TypeValues:
Public Function GetTypedValues(ByVal resultBuffer As ResultBuffer) As TypedValue()
Dim m_Result As New List(Of TypedValue)
If resultBuffer IsNot Nothing Then
For Each m_TypedValue As TypedValue In resultBuffer
m_Result.Add(m_TypedValue)
Next
End If
Return m_Result.ToArray
End Function
Now, use either For...Each loop or ResultBuffers' Enumerator - performance stays the same (on VB.NET, not sure about C#).
Regards,
Maksim Sestic