PDA

View Full Version : C# .NET 4 and System.__ComObject (MapPoint 2010)



christof
10-04-2012, 04:44 AM
Hello, this would me me first post here :) I've started with developing an winform application using C#. There is a COM reference in my project Microsoft MapPoint 18.0 Object Library (Europe). Application works fine, shows me the route etc. But I need to handle that event:

private void axMappointControl1_SelectionChange(object sender, _IMappointCtrlEvents_SelectionChangeEvent e)
{
//if new selection is pushpin do something
object s = e.pNewSelection;

Shape shape = e.pNewSelection as Shape;

if (shape != null)
MessageBox.Show(shape.Type.ToString()); //never shown...
}

Everytime e.pNewSelection is System.__ComObject. (e.pOldSelection as well)
I can not cast it to anything, the Pushpin or anything else will always be null after assignement.

Help would be very appreciated here!

Thanks.

Winwaed
10-04-2012, 08:11 AM
According to the documentation, the SelectionChange has two parameters: NewSelection and OldSelection.

Are you getting the objects confused so that "NewSelection" is actually being passed to Sender?

christof
10-24-2012, 10:25 AM
Actually everything works fine when I changed Framework to 3.5