<?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 Re: Error Creating a Map in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817304#M2653</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can this be&amp;nbsp;marked as the correct answer when it does not answer the question? none of the Pro Snippiest&amp;nbsp;show create a new map definition, add it to the current project, and make it the active map.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 13 Feb 2020 01:21:03 GMT</pubDate>
    <dc:creator>RichardDaniels</dc:creator>
    <dc:date>2020-02-13T01:21:03Z</dc:date>
    <item>
      <title>Error Creating a Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817302#M2651</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;"This method or property must be called on the thread this object was created on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I get this exception when creating a Map object either from an existing map or creating a new map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt; Map map = null;&lt;BR /&gt; //ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Open");&lt;BR /&gt; var mapProjectItems = Project.Current.GetItems&amp;lt;MapProjectItem&amp;gt;();&lt;BR /&gt; if (mapProjectItems.Count() &amp;gt; 0)&lt;BR /&gt; {&lt;BR /&gt; var mapProjectItem = mapProjectItems.First();&lt;BR /&gt; //FirstOrDefault(mpi =&amp;gt; mpi.Name.Equals("World Map"));&lt;BR /&gt; map = mapProjectItem.GetMap();&lt;BR /&gt; ProApp.Panes.CreateMapPaneAsync(map);&lt;BR /&gt; }&lt;BR /&gt; else&lt;BR /&gt; {&lt;BR /&gt; map = MapFactory.Instance.CreateMap("World Map", ArcGIS.Core.CIM.MapType.Map, ArcGIS.Core.CIM.MapViewingMode.Map, Basemap.Terrain);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mitch&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 02 Feb 2018 18:39:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817302#M2651</guid>
      <dc:creator>MitchWolberg</dc:creator>
      <dc:date>2018-02-02T18:39:35Z</dc:date>
    </item>
    <item>
      <title>Re: Error Creating a Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817303#M2652</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Mitch,&lt;/P&gt;&lt;P&gt;You need to use QueuedTask.Run.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-MapAuthoring"&gt;https://github.com/Esri/arcgis-pro-sdk/wiki/ProSnippets-MapAuthoring&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 05 Feb 2018 09:18:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817303#M2652</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2018-02-05T09:18:01Z</dc:date>
    </item>
    <item>
      <title>Re: Error Creating a Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817304#M2653</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;How can this be&amp;nbsp;marked as the correct answer when it does not answer the question? none of the Pro Snippiest&amp;nbsp;show create a new map definition, add it to the current project, and make it the active map.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 13 Feb 2020 01:21:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817304#M2653</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2020-02-13T01:21:03Z</dc:date>
    </item>
    <item>
      <title>Re: Error Creating a Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817305#M2654</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Richard,&lt;/P&gt;&lt;P&gt;&amp;nbsp;When you click the link in the answer it will take you to a snippet that shows the "&lt;SPAN style="background-color: #ffffff;"&gt;MapFactory.Instance.CreateMap" method you asked about in your original question.&amp;nbsp; The snippet shows that you have to call the CreateMap method from within the context of the MCT or main CIM thread using QueuedTask.Run.&amp;nbsp; Usually you&amp;nbsp;can see the MCT requirement&amp;nbsp;for&amp;nbsp;any method by looking at the API help for the method or through intellisense (when you hover your mouse pointer over the method name in Visual Studio).&amp;nbsp; The requirement for MCT is listed in the help always like this:&amp;nbsp; "This method must be called on&amp;nbsp;the MCT. Use QueuedTask.Run".&amp;nbsp; So the fix for your snippet would look like this:&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="keyword token"&gt;protected&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;override&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;async&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;void&lt;/SPAN&gt; &lt;SPAN class="token function"&gt;OnClick&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
&lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
  Map map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="keyword token"&gt;null&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="comment token"&gt;//ArcGIS.Desktop.Framework.Dialogs.MessageBox.Show("Open");&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; mapProjectItems &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; Project&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Current&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;GetItems&lt;SPAN class="operator token"&gt;&amp;lt;&lt;/SPAN&gt;MapProjectItem&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
  &lt;SPAN class="keyword token"&gt;await&lt;/SPAN&gt; QueuedTask&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Run&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt;&lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;if&lt;/SPAN&gt; &lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;mapProjectItems&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;Count&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt; &lt;SPAN class="operator token"&gt;&amp;gt;&lt;/SPAN&gt; &lt;SPAN class="number token"&gt;0&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
      &lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; mapProjectItem &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; mapProjectItems&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;First&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
      &lt;SPAN class="comment token"&gt;//FirstOrDefault(mpi =&amp;gt; mpi.Name.Equals("World Map"));&lt;/SPAN&gt;
      map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; mapProjectItem&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;GetMap&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
      ProApp&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Panes&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;CreateMapPaneAsync&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;map&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
    &lt;SPAN class="keyword token"&gt;else&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;{&lt;/SPAN&gt;
      map &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; MapFactory&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Instance&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;CreateMap&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;(&lt;/SPAN&gt;&lt;SPAN class="string token"&gt;"World Map"&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ArcGIS&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Core&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CIM&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapType&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; ArcGIS&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Core&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;CIM&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;MapViewingMode&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Map&lt;SPAN class="punctuation token"&gt;,&lt;/SPAN&gt; Basemap&lt;SPAN class="punctuation token"&gt;.&lt;/SPAN&gt;Terrain&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;
    &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;
  &lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;)&lt;/SPAN&gt;&lt;SPAN class="punctuation token"&gt;;&lt;/SPAN&gt;


&lt;SPAN class="punctuation token"&gt;}&lt;/SPAN&gt;&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:39:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817305#M2654</guid>
      <dc:creator>Wolf</dc:creator>
      <dc:date>2021-12-12T09:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: Error Creating a Map</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817306#M2655</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I had the this same error, in my case I fixed the issue by making my method public.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;public static async void LoadNewProject(CreateProjectSettings ps2)&lt;BR /&gt; {&lt;BR /&gt; //load the newly defined project; must be public to avoid threading errors!&lt;BR /&gt; try&lt;BR /&gt; {&lt;BR /&gt; Project thePrj = await Project.CreateAsync(ps2);&lt;BR /&gt; await Project.OpenAsync(thePrj.URI.ToString());&lt;BR /&gt; }&lt;BR /&gt; catch (Exception eX)&lt;BR /&gt; {&lt;BR /&gt; //do&amp;nbsp;something&lt;BR /&gt; TrackErrorLibrary.reportError("SystemError", Project.Current.Name.ToString() + ". " + eX.Message + ". ");&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Feb 2020 19:28:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map/m-p/817306#M2655</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2020-02-19T19:28:21Z</dc:date>
    </item>
  </channel>
</rss>

