<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic nullreferenceexception error in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/nullreferenceexception-error/m-p/106574#M2789</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;im trying to creat a custom toolbar with tools for arcmap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i have a combobox in it and added some codes in the ComboBox1_SelectedIndexChange() to remove all layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's the code added&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;private sub ComboBox1_SelectedIndexChange()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;removeLayers()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sub removeLayers()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMxDoc as IMxDocument = DirectCast(m_Application.Document, IMxDocument)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMap as IMap = pMxDoc.FocusMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pMap.ClearLayers()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pMxDoc.UpdateContents()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pMxDoc.ActiveView.Refresh()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but when I start debugging to test if the code is working I get the error&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NullReferenceException was unhandled bu user code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Object reference not set to an instance of an object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;can someone help me with this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i'm using VS2008 and arcgis 9.3&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 09 Jun 2011 02:22:45 GMT</pubDate>
    <dc:creator>Gregory_KevinMorales</dc:creator>
    <dc:date>2011-06-09T02:22:45Z</dc:date>
    <item>
      <title>nullreferenceexception error</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/nullreferenceexception-error/m-p/106574#M2789</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;im trying to creat a custom toolbar with tools for arcmap.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i have a combobox in it and added some codes in the ComboBox1_SelectedIndexChange() to remove all layers.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;here's the code added&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;private sub ComboBox1_SelectedIndexChange()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;removeLayers()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;sub removeLayers()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMxDoc as IMxDocument = DirectCast(m_Application.Document, IMxDocument)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Dim pMap as IMap = pMxDoc.FocusMap&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pMap.ClearLayers()&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;pMxDoc.UpdateContents()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;pMxDoc.ActiveView.Refresh()&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;end sub&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;but when I start debugging to test if the code is working I get the error&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;NullReferenceException was unhandled bu user code&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Object reference not set to an instance of an object.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;can someone help me with this...&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;i'm using VS2008 and arcgis 9.3&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 09 Jun 2011 02:22:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/nullreferenceexception-error/m-p/106574#M2789</guid>
      <dc:creator>Gregory_KevinMorales</dc:creator>
      <dc:date>2011-06-09T02:22:45Z</dc:date>
    </item>
  </channel>
</rss>

