Welcome to MapForums!

Register, sign in, or use Facebook Connect above to join in and participate in the forum.

When you are signed in, this message, the ads in this row, and the red-underlined link ads all go away.

Subscribe to receive our newsletter.
Subscribe Unsubscribe
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

MapPoint crashs after closing the application

This is a discussion on MapPoint crashs after closing the application within the MapPoint Desktop Discussion forums, part of the Map Forums category; Hello, I developp an add-in for Mappoint, and every times I close MapPoint an error message comes I want to ...

  1. #1
    Elbarto is offline Junior Member Yellow Belt
    Join Date
    Mar 2006
    Posts
    13

    MapPoint crashs after closing the application

    Hello,

    I developp an add-in for Mappoint, and every times I close MapPoint an error message comes

    I want to know tips for developping add-in to avoid theses crashs after closing MapPoint ?

    maybe I must do something in my source code ( method "OnDisconnection" ) to have a clean exit for MapPoint ?

    I have the book "Programming MaPpoint in .Net" by Chandu Thota but it says nothing about clean exit when we developp add-in for Mappoint,

    help me to fix this problem please

    thanks

  2. #2
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    Nobody can help if you dont tell the exact error meage, and the offending line of code !

  3. #3
    Elbarto is offline Junior Member Yellow Belt
    Join Date
    Mar 2006
    Posts
    13
    I use this code when my add-in is close:


    public void OnDisconnection(Extensibility.ext_DisconnectMode disconnectMode, ref System.Array custom)
    {
    if(app != null)
    {
    app.Quit( );
    app = null;
    }
    }
    "app" is the mappoint process


    public class Test
    {
    private MapPoint.Application app;

    //constructor
    public Test(object application)
    {
    app = application as MapPoint.Application;

    }
    maybe my method is incorrect ?

    I want to know the general advice to make a correct add-in, fo a perfect exit of the application

  4. #4
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    MP.Quit is the correct method to terminate the application object. But I never wrote an add-on, so maybe situation is different. Hopefully someone else drops in with the right knowledge.

  5. #5
    Th.M.Mädzulat is offline Junior Member Yellow Belt
    Join Date
    Dec 2005
    Posts
    17
    Hi Elbarto,
    I've got the same problem. Writing in VB .net the relevant code is:

    Public Class connect
    Dim applicationObject As Object
    Dim addInInstance As Object
    Dim FormAddIn As MyAddinProject.Form1

    Protected Friend Shared MPApp As MapPoint.Application


    Private Sub ReleaseObject(ByVal MPApp As Object)
    Try

    Try 'cause it's not sure, if the user already has close it
    FormAddIn.Close()
    Catch ex As Exception
    End Try

    System.Runtime.InteropServices.Marshal.ReleaseComO bject(MPApp)
    Catch
    Finally
    MPApp = Nothing
    End Try

    End Sub

    Public Sub OnDisconnection(ByVal RemoveMode As Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnDisconnection
    On Error Resume Next
    If RemoveMode <> Extensibility.ext_DisconnectMode.ext_dm_HostShutdo wn Then _
    Call OnBeginShutdown(custom)
    MPApp.RemoveCommands("my addin")
    ReleaseObject(MPApp)
    End Sub

    Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
    applicationObject = application
    addInInstance = addInInst
    MPApp = CType(application, MapPoint.Application)
    ' Add an item to the Tools menu in MapPoint.
    MPApp.AddCommand("my addin", "ShowAddInForm", Me)
    End Sub

    Public Sub ShowAddInForm()
    FormAddIn = New MyAddinProject.Form1
    FormAddIn.Show()
    End sub
    End Class


    Public Class Form1
    objApp = GetObject(, "MapPoint.Application")
    objMap = objApp.ActiveMap

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
    Call CleanMap()
    objMap = Nothing
    objApp = Nothing
    End Sub

    End Class

    ...and the error message is something like: "MapPoint has detected an error and has to shut down...", - I'm using the German edition 2002 with the European map.
    I don't know what's the problem...
    Would be great if someone can explain how to correctly clean up the addin before MapPoint closes, - because the error-message doesn't appear when VS .net closes my addin.

    thank the one
    martin

  6. #6
    Elbarto is offline Junior Member Yellow Belt
    Join Date
    Mar 2006
    Posts
    13
    up, my probem is not fixed, help please

  7. #7
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi,

    If it is in C# and you strip your project to a few lines of code just to demonstrate the error you may private email it to me. I have some spare time tomorrow so I can "try" to check it out.

    However I did not do add-ins, so I have no experiance with it. Anyway I can try

  8. #8
    Th.M.Mädzulat is offline Junior Member Yellow Belt
    Join Date
    Dec 2005
    Posts
    17
    ...found a descriptions for VB and C# on
    http://support.microsoft.com/?scid=k...530&sid=global
    http://support.microsoft.com/?scid=k...530&sid=global

    The point is: "...Both the OnStartupComplete and OnBeginShutdown methods are called when the host application has left or is entering a state in which user interaction should be avoided because the application is busy loading or unloading itself from memory."

    I am not that fit in system internal and threads etc. and still hadn't time to try it out but I'm sure that's it.
    The main problem is not to clean up the right way but at the right moment. That explains why sometimes the error message appeard and sometimes not...

    greetings an Merry Easter
    martin

  9. #9
    Wilfried is offline Senior Member Black Belt
    Join Date
    Nov 2004
    Location
    Belgium
    Posts
    2,433
    Hi Martin,

    Thanks for feedback. I did not study the articles (sorry) but the right time could be when the mappoint application enters the message pump. This can be done by posting a WM_QUIT to the mappoint application using the windows API PostMessage function.

  10. #10
    Th.M.Mädzulat is offline Junior Member Yellow Belt
    Join Date
    Dec 2005
    Posts
    17
    Hallo Wilfried,
    you don't have to be sorry for don't doing things that are not really your business! So this here should be more a short hint for those who are interested in as an answer...
    The main cleaning up doesn't belong to the OnDisconnection method of the IDTExtensibility2 interface but to the OnBeginShutDown method.
    That is at least the point. If done everything what belongs to the addin is finished when the MapPoint application is starting its unloading. No further problems.

    Thank you for care
    thomas martin

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Disabling closing of MapPoint?
    By MD2000 in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 05-09-2005, 04:57 PM
  2. Closing: MapPoint process stilll running
    By MD2000 in forum MapPoint Desktop Discussion
    Replies: 4
    Last Post: 04-29-2005, 08:58 AM
  3. Closing Without Saving A territory map
    By Yazzy in forum MapPoint Desktop Discussion
    Replies: 3
    Last Post: 04-27-2005, 02:26 PM
  4. Closing without saving
    By Mudrover in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 01-30-2005, 07:49 AM
  5. I am trying to use the Mappoint in my application ....
    By Anonymous in forum MapPoint Desktop Discussion
    Replies: 1
    Last Post: 12-03-2001, 09:53 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96