gkmorales

m_Application is set to nothing

Discussion created by gkmorales on Aug 17, 2011
i cant load or remove layers 'coz m_Application is set to nothing...

i'm using 9.3 and vs 2008...

i am using a combobox event in a usercontrol that is in the toolbar...

in the OnCreate method of the usercontrol, i have added the m_application = DirectCast(hook, IApplication) and filled the combobox with stuffs to load maps...

then in the ComboBox1_SelectionChangeCommitted method i have added the code below to remove all loaded layers but im getting an object reference not set to an instance of an object error...

Try
        Dim pMxDoc As IMxDocument = TryCast(m_Application.Document, IMxDocument)
      
        Dim pMap As IMap = pMxDoc.ActiveView.FocusMap

        pMap.ClearLayers()

        pMxDoc.UpdateContents()

        pMxDoc.ActiveView.Refresh()
Catch ex As Exception
            MsgBox(ex.Message)
End Try

sorry for my bad explanation...

Outcomes