AnsweredAssumed Answered

COM object that has been separated from its underlying RCW cannot be used.

Question asked by tjoobaa1 on Feb 10, 2012
Latest reply on Feb 13, 2012 by agray1
How can I avoid "COM object that has been separated from its underlying RCW cannot be used."?

Is this code completely wrong?
I am trying to start listeners for OnEditorStartEditing and OnEditorStopEditing like this:
    Public Sub EditorEvent_Add()
        EditorEvent_Remove()
        Dim pID As esriSystem.UID = New esriSystem.UID : pID.Value = "esriEditor.Editor"

        Try
            m_EditorEventOnStartEditing = New Editor.IEditEvents_OnStartEditingEventHandler(AddressOf OnEditorStartEditing)
            AddHandler CType(CType(m_Application.FindExtensionByCLSID(pID), Editor.IEditor), Editor.IEditEvents_Event).OnStartEditing, m_EditorEventOnStartEditing
        Catch ex As Exception
            MsgBox("Message" & vbNewLine & ex.Message & vbNewLine & "StackTrace" & vbNewLine & ex.StackTrace, MsgBoxStyle.OkOnly, "OnEditorStartEditing")
        End Try
        Try
            m_EditorEventOnStopEditing = New Editor.IEditEvents_OnStopEditingEventHandler(AddressOf OnEditorStopEditing)
            AddHandler CType(CType(m_Application.FindExtensionByCLSID(pID), Editor.IEditor), Editor.IEditEvents_Event).OnStopEditing, m_EditorEventOnStopEditing
        Catch ex As Exception
            MsgBox("Message" & vbNewLine & ex.Message & vbNewLine & "StackTrace" & vbNewLine & ex.StackTrace, MsgBoxStyle.OkOnly, "OnEditorStopEditing")
        End Try
    End Sub

Attachments

Outcomes