dsaldana

IHookhelper and IMap

Discussion created by dsaldana on Oct 4, 2011
Latest reply on Oct 4, 2011 by rlwatson
Hello,

I am very new to .NET programming within ArcObjects.   I am in the process of attempting to upgrade our VB6 code to .NET.

First I am debugging the code, by running it within the Visual Studio environment.   That maybe wrong in itself, but it was just something I figured out that got me this far.  

So I want to go through a list of layers, however, when I encounter the line below.

Dim pLayers As IEnumLayer = m_Map.Layers((CType(pUID, ESRI.ArcGIS.esriSystem.UID)), True)

I get 'Object reference not set to an instance of an object'.    I've done some debugging and have come to find out that when I start setting up my m_Map it gets assigned 'nothing'.   (Code below)

    Private m_pHookhelper As IHookHelper
    Private m_mxdoc As IMxDocument
    Private m_Map As IMap

    If (m_pHookhelper Is Nothing) Then m_pHookhelper = New HookHelperClass
    m_Map = m_pHookhelper.FocusMap

I believe I am testing this incorrectly, but I am not sure.

Please let me know.   Any advice is appreciated.

Outcomes