1

I have simple code that basically opens mappoint and imports addresses into it then calculates route. Works perfectly except MapPoint.exe process stays in system even after closing Mappoint.

Didnt notice such problem with older versions of MapPoint.

jM2.me
  • 3,839
  • 12
  • 44
  • 58

2 Answers2

1

You need to explicitly set your variable to NULL after closing MapPoint. If you don't, a dangling reference to the automation object remains, and MapPoint thinks something is still using it (even though you'd think reference counting would detect it's not).

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • Well I could set it to null but I need to do so only when mappoint itself is closed. Is there like an event or something? – jM2.me May 05 '11 at 00:42
  • No. You need to do it when you're through using it, whether MapPoint itself is closed or not. It's a reference count issue - whenever MapPoint is opened via automation, a counter is incremented; MapPoint won't close until that counter decrements to 0 again. No event is needed - it's automated by COM. IOW, when you MapPoint.Quit, you need to NULL your variable afterwards. – Ken White May 05 '11 at 00:55
0

@jm2.me: The only MapPoint reference you need at closure is the one to MapPoint.Application. Any others can be re-thought. Also look at the Map's Saved property, and the UserControl property. These can interfere at closure.

btw, Ken White is fundamentally correct - the properties mentioned above are just things which can cause problems in certain edge cases - and you imply that might refer to you.

winwaed
  • 7,645
  • 6
  • 36
  • 81