View Full Version : Problem with ObjectsFromPoint

10-07-2005, 03:12 AM
I'm having trouble with the ObjectsFromPoint method. The following code throws an exception whenever there is a TextBox "under" the x, y.

MapPoint.FindResult fr = axMappointCtrl.ActiveMap.ObjectsFromPoint(x,y)
foreach(object o in fr)
Debug.Writeline("Doing nothing...");

The method is fine as long as there is no textBox returned to the fr collection.

When it is, the following exeption stack can be traced:

at System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32 errorCode, IntPtr errorInfo)
at System.Runtime.InteropServices.Marshal.ThrowExcept ionForHR(Int32 errorCode)
at System.Runtime.InteropServices.CustomMarshalers.En umeratorViewOfEnumVariant.GetNextElems()
at System.Runtime.InteropServices.CustomMarshalers.En umeratorViewOfEnumVariant.MoveNext()

Please, can anyone help me with this?


10-10-2005, 01:05 PM

What is the offending line of code ?

10-11-2005, 08:00 AM

I read this on a Microsoft page, guess this is what happens in my code.

The Map.ObjectsFromPoint method sometimes creates an invalid FindResults object. The count of the results is larger than the actual number of found items

To answer your question: The exception is thrown in the foreach loop and since I don't do anythin in it it is the iteration itself that fails.


10-13-2005, 01:23 AM

Thanks for feedback. This is probably the reason.