<?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 Using maptool with dockpane causes SystemNullReferenceException when calling dockpane from maptool in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029638#M6239</link>
    <description>&lt;P&gt;I am working on a tool that uses a dockpane to display results from features in a box from a maptool.&amp;nbsp; I actually have already created this tool with a windows form and it works really well except for one issue that I don't think can be resolved, so I'm looking at the dockpane, which I believe is the only other way to get a form in Pro.&amp;nbsp; However, I open the dockpane, then draw the box with the maptool, and when I call a function in the dockpane a null reference exception is returned.&amp;nbsp; The data that I'm passing to the dockpane is not null, and I even tested it without passing any data and the dockpane still comes back null.&lt;/P&gt;&lt;P&gt;I am using Esri sample "MapToolIdentifyWithDockpane" as a reference, and I have everything set up the same way as in that sample.&amp;nbsp; The sample works, mine does not.&lt;/P&gt;&lt;P&gt;I have this in the config.daml for the dockpane:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;dockPanes&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;dockPane id="CustomIDDockPane_dpIDTools" caption="dpIDTools" className="dpIDToolsViewModel" dock="float" dockWith="esri_core_projectDockPane"&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;content className="dpIDToolsView" /&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;/dockPane&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;/dockPanes&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;This is what I have in Module1 to define the dockpane:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;internal class Module1 : Module&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;private static Module1 _this = null;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;private static dpIDToolsViewModel _dpIDToolsVM = null;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;public static Module1 Current&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;get&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;return _this ?? (_this = (Module1)FrameworkApplication.FindModule("CustomIDDockPane_Module"));&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;internal static dpIDToolsViewModel dpIDToolsVM { get; set; }&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I call this from the tool, this is where the error occurs:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399"&gt;&lt;EM&gt;Module1.dpIDToolsVM.LoadIDResults(mapLayerNames, feat);&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;This is the code in the viewmodel that the above line is calling:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;internal void LoadIDResults(List&amp;lt;string&amp;gt; layerNames, Dictionary&amp;lt;BasicFeatureLayer, List&amp;lt;long&amp;gt;&amp;gt; featureLayerList)&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;List&amp;lt;IDFeaturesInLayer&amp;gt; iList = new List&amp;lt;IDFeaturesInLayer&amp;gt;();&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;foreach (KeyValuePair&amp;lt;BasicFeatureLayer, List&amp;lt;long&amp;gt;&amp;gt; b in featureLayerList)&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;IDFeaturesInLayer i = new IDFeaturesInLayer();&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;i.Value = b.Key;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;i.Text = b.Key.ToString();&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;iList.Add(i);&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Thank you in advance for any assistance offered.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Jeff&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 23 Feb 2021 17:50:04 GMT</pubDate>
    <dc:creator>JeffSauder</dc:creator>
    <dc:date>2021-02-23T17:50:04Z</dc:date>
    <item>
      <title>Using maptool with dockpane causes SystemNullReferenceException when calling dockpane from maptool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029638#M6239</link>
      <description>&lt;P&gt;I am working on a tool that uses a dockpane to display results from features in a box from a maptool.&amp;nbsp; I actually have already created this tool with a windows form and it works really well except for one issue that I don't think can be resolved, so I'm looking at the dockpane, which I believe is the only other way to get a form in Pro.&amp;nbsp; However, I open the dockpane, then draw the box with the maptool, and when I call a function in the dockpane a null reference exception is returned.&amp;nbsp; The data that I'm passing to the dockpane is not null, and I even tested it without passing any data and the dockpane still comes back null.&lt;/P&gt;&lt;P&gt;I am using Esri sample "MapToolIdentifyWithDockpane" as a reference, and I have everything set up the same way as in that sample.&amp;nbsp; The sample works, mine does not.&lt;/P&gt;&lt;P&gt;I have this in the config.daml for the dockpane:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;dockPanes&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;dockPane id="CustomIDDockPane_dpIDTools" caption="dpIDTools" className="dpIDToolsViewModel" dock="float" dockWith="esri_core_projectDockPane"&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;content className="dpIDToolsView" /&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;/dockPane&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;&amp;lt;/dockPanes&amp;gt;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;This is what I have in Module1 to define the dockpane:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;internal class Module1 : Module&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;private static Module1 _this = null;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;private static dpIDToolsViewModel _dpIDToolsVM = null;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;public static Module1 Current&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;get&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;return _this ?? (_this = (Module1)FrameworkApplication.FindModule("CustomIDDockPane_Module"));&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;internal static dpIDToolsViewModel dpIDToolsVM { get; set; }&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;I call this from the tool, this is where the error occurs:&lt;/P&gt;&lt;P&gt;&lt;FONT color="#333399"&gt;&lt;EM&gt;Module1.dpIDToolsVM.LoadIDResults(mapLayerNames, feat);&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;This is the code in the viewmodel that the above line is calling:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;internal void LoadIDResults(List&amp;lt;string&amp;gt; layerNames, Dictionary&amp;lt;BasicFeatureLayer, List&amp;lt;long&amp;gt;&amp;gt; featureLayerList)&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;List&amp;lt;IDFeaturesInLayer&amp;gt; iList = new List&amp;lt;IDFeaturesInLayer&amp;gt;();&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;foreach (KeyValuePair&amp;lt;BasicFeatureLayer, List&amp;lt;long&amp;gt;&amp;gt; b in featureLayerList)&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;{&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;IDFeaturesInLayer i = new IDFeaturesInLayer();&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;i.Value = b.Key;&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;i.Text = b.Key.ToString();&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;iList.Add(i);&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#333399"&gt;}&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Thank you in advance for any assistance offered.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#000000"&gt;Jeff&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 17:50:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029638#M6239</guid>
      <dc:creator>JeffSauder</dc:creator>
      <dc:date>2021-02-23T17:50:04Z</dc:date>
    </item>
    <item>
      <title>Re: Using maptool with dockpane causes SystemNullReferenceException when calling dockpane from maptool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029726#M6240</link>
      <description>&lt;P&gt;I created a new AddIn project ProAppModule1, then added two items: a Dockpane and a MapTool.&lt;/P&gt;&lt;P&gt;I added code to the OnSketchCompleteAsync in MapTool1.cs using the id from the daml file (ProAppModule1_Dockpane1):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;protected override Task&amp;lt;bool&amp;gt; OnSketchCompleteAsync(Geometry geometry)
{
    // added this code:
    var dockPaneID = "ProAppModule1_Dockpane1";
    var paneVm = FrameworkApplication.DockPaneManager.Find(dockPaneID)
        as Dockpane1ViewModel;
    if (paneVm != null)
    {
        paneVm.Heading = Environment.TickCount.ToString();
    }
    return base.OnSketchCompleteAsync(geometry);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I ran it, clicked the Maptool1 button, then clicked on the map twice:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KirkKuykendall1_0-1614110668263.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/6717i7848E0CE0DBBDCAF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KirkKuykendall1_0-1614110668263.png" alt="KirkKuykendall1_0-1614110668263.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Note that I made no changes to the Module1.cs or Dockpane1ViewModel.cs.&lt;/P&gt;&lt;P&gt;The only change was to MapTool1.cs.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KirkKuykendall1_1-1614111067697.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/6718iB3E9D02A8EE5777D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="KirkKuykendall1_1-1614111067697.png" alt="KirkKuykendall1_1-1614111067697.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 20:51:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029726#M6240</guid>
      <dc:creator>KirkKuykendall1</dc:creator>
      <dc:date>2021-02-23T20:51:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using maptool with dockpane causes SystemNullReferenceException when calling dockpane from maptool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029813#M6243</link>
      <description>&lt;P&gt;Thanks Kirk, that worked.&amp;nbsp; The sample that I was looking at didn't have it defined that way, it was using the definition in Module1.&amp;nbsp; This was much simpler.&amp;nbsp; I appreciate you looking at this, this will get me going on to the next challenge in this app.&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeff&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 22:37:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029813#M6243</guid>
      <dc:creator>JeffSauder</dc:creator>
      <dc:date>2021-02-23T22:37:38Z</dc:date>
    </item>
    <item>
      <title>Re: Using maptool with dockpane causes SystemNullReferenceException when calling dockpane from maptool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029822#M6245</link>
      <description>&lt;P&gt;What they are suggesting would scale a better as your code evolves.&amp;nbsp; When things get complicated its often better to have the each component talk to the module instead of talking directly to each other.&lt;/P&gt;</description>
      <pubDate>Tue, 23 Feb 2021 22:48:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029822#M6245</guid>
      <dc:creator>KirkKuykendall1</dc:creator>
      <dc:date>2021-02-23T22:48:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using maptool with dockpane causes SystemNullReferenceException when calling dockpane from maptool</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029972#M6248</link>
      <description>&lt;P&gt;I'm going to move forward with this one, as it's a fairly simple app, but definitely will continue trying to get the other method to work.&amp;nbsp; This new api is definitely a learning curve but I'm getting a lot more used to it.&lt;/P&gt;</description>
      <pubDate>Wed, 24 Feb 2021 13:31:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/using-maptool-with-dockpane-causes/m-p/1029972#M6248</guid>
      <dc:creator>JeffreySauder</dc:creator>
      <dc:date>2021-02-24T13:31:42Z</dc:date>
    </item>
  </channel>
</rss>

