|
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 |