PDA

View Full Version : Problem with ObjectsFromPoint



pobe
10-07-2005, 03:12 AM
Hi,
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?

//pobe

Wilfried
10-10-2005, 01:05 PM
Hi,

What is the offending line of code ?

pobe
10-11-2005, 08:00 AM
Hi,

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.

/pobe

Wilfried
10-13-2005, 01:23 AM
Hi,

Thanks for feedback. This is probably the reason.