View Single Post

  #1 (permalink)  
Old 02-16-2008
BobFromBoston BobFromBoston is offline
Senior Member
Green Belt
 
Join Date: Jul 2005
Posts: 105
Need to close then open MapPoint COM Object

I have had some odd behavior and memory issues with MapPoint 2004 and was advised by Microsoft that I would be best to close the COM object one in a while, versus having my program leave the same instance running for 12 hours at a clip. I see the inherent logic of this plan and am trying to stop, then restart my instance of MapPoint every 15 minutes or so.

This is the function I use to create an instance of MapPoint:

private MapPoint.Map MakeNewMap( AxMapPoint.AxMappointControl mpControl )
{
string objTemplate = Configuration.MapPointDir;
mpControl.NewMap(objTemplate);
return mpControl.ActiveMap;
}

Can anyone give me the code I need to unload this instance? When I use this function it fails:

public void RefreshMapPointComObject()
{
axMappointControl1.ActiveMap.Saved = true;
axMappointControl1.Dispose();
MakeNewMap(axMappointControl1);
}


I get COM Object seperated from its underlying connection.

How do I destroy the COM object completely then recreate it so I can start using it again?? I have made sure to remove any and all references to it.

I assume if I get the right call (CloseMap() does not work) that I can see it close in Task manager. Am I right about that? Does it take some time for this to take place?

I even tried this in an attempt to remove the MapPoint COM object:

axMappointControl1.ActiveMap.Saved = true;
axMappointControl1.CloseMap();
Trip.NAR(axMappointControl1.ActiveMap);
this.Controls.Remove(this.axMappointControl1);


but with no luck. The MapPoint.exe program is still listed in the Processes page of the Task Manager.

Can anyone tell me how to get rid of it?? I need to do this so I can then reload it.


Thanks,
Bob
Reply With Quote