<?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 a core host Application in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map-in-a-core-host-application/m-p/1153368#M7932</link>
    <description>&lt;P&gt;&lt;SPAN&gt;In addition to &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;&amp;nbsp;, attempting to access any of the ArcGIS Pro UI elements or types in other assemblies in an&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;ArcEngine-like&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;fashion will crash the program. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Details:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/proconcepts-CoreHost" target="_self"&gt;&lt;SPAN&gt;Corehost Conceptual doc&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 14 Mar 2022 14:44:53 GMT</pubDate>
    <dc:creator>Aashis</dc:creator>
    <dc:date>2022-03-14T14:44:53Z</dc:date>
    <item>
      <title>Error creating a map in a core host Application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map-in-a-core-host-application/m-p/1153316#M7926</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;I have to write an console application, that creates an lyrx-File of a wms-service.&lt;/P&gt;&lt;P&gt;I should be able to create a Layer using the Layer Factory, but it needs a map.&lt;/P&gt;&lt;P&gt;So I try to Create an empty Map first.&lt;/P&gt;&lt;P&gt;When I do, I get an Exception:&lt;/P&gt;&lt;BLOCKQUOTE&gt;&lt;P&gt;System.NullReferenceException&lt;BR /&gt;HResult = 0x80004003&lt;BR /&gt;Nachricht = Der Objektverweis wurde nicht auf eine Objektinstanz festgelegt.&lt;BR /&gt;Quelle = ArcGIS.Desktop.Mapping&lt;BR /&gt;Stapelüberwachung:&lt;BR /&gt;at ArcGIS.Desktop.Mapping.MapFactory.&amp;lt;&amp;gt;c__DisplayClass5_0.&amp;lt;CreateMap&amp;gt;b__0()&lt;BR /&gt;at ArcGIS.Desktop.Internal.Mapping.Utilities.MakeBasicServiceCall[T](Func`1 serviceCall)&lt;BR /&gt;at ArcGIS.Desktop.Mapping.MapFactory.CreateMap(String name, MapType mapType, MapViewingMode defaultViewingMode, Basemap basemap)&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Unfortunately I have no idea what my error is.&lt;/P&gt;&lt;P&gt;Thank you, for reading&lt;/P&gt;&lt;P&gt;Andreas Ruloffs&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using ArcGIS.Core.CIM;
using ArcGIS.Core.Hosting;
using ArcGIS.Desktop.Framework.Threading.Tasks;
using ArcGIS.Desktop.Mapping;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace ProCoreHost3
{
    class Program
    {
        //[STAThread] must be present on the Application entry point
        [STAThread]
        static void Main(string[] args)
        {

            AppDomain currentDomain = AppDomain.CurrentDomain;
            currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveProAssemblyPath);
            if (args.Length != 3)
            {
                Console.Out.WriteLine("usage: CreateWMSLyr &amp;lt;wmsurl&amp;gt; &amp;lt;visibleLayer seperated by commas&amp;gt; &amp;lt;outputfile name");
                Environment.Exit(1);
            }
            String wmsURL = args[0];
            String visibleLayerStr = args[1];
            String outFile = args[2];

            String[] visibleLayer = visibleLayerStr.Split(new char[] { ',' });

            MainAsync(wmsURL, visibleLayer, outFile).GetAwaiter().GetResult();
        }

        static async Task MainAsync(String wmsURL, String[] visibleLayer, String outFile)
        {
            //Call Host.Initialize before constructing any objects from ArcGIS.Core
            try
            {
                Host.Initialize();
            }
            catch (Exception e)
            {
                // Error (missing installation, no license, 64 bit mismatch, etc.)
                Console.WriteLine(string.Format("Initialization failed: {0}", e.Message));
                return;
            }

            Map map = MapFactory.Instance.CreateMap("test", MapType.Map, MapViewingMode.Map, Basemap.None);

            CIMInternetServerConnection serverConnection = new CIMInternetServerConnection
            {
                URL = wmsURL
            };
            CIMWMSServiceConnection connection = new CIMWMSServiceConnection { ServerConnection = serverConnection };

            Layer layer = LayerFactory.Instance.CreateLayer(connection, MapView.Active.Map);
            LayerDocument layerdocument = new LayerDocument(layer);

            layerdocument.Save(outFile);
        }
        static Assembly ResolveProAssemblyPath(object sender, ResolveEventArgs args)
        {
            string folderPath = @"C:\Program Files\ArcGIS\Pro\bin"; //Get this from registry
            string assemblyPath = Path.Combine(folderPath, new AssemblyName(args.Name).Name + ".dll");
            if (!File.Exists(assemblyPath)) return null;
            Assembly assembly = Assembly.LoadFrom(assemblyPath);
            return assembly;
        }
    }
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 14 Mar 2022 12:47:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map-in-a-core-host-application/m-p/1153316#M7926</guid>
      <dc:creator>AndreasRuloffs2</dc:creator>
      <dc:date>2022-03-14T12:47:11Z</dc:date>
    </item>
    <item>
      <title>Re: Error creating a map in a core host Application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map-in-a-core-host-application/m-p/1153328#M7929</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Corehost supports access to GDB and Geometry only.&amp;nbsp;CoreHost application cannot use many of the constructs provided by the ArcGIS.Desktop dlls&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 13:36:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map-in-a-core-host-application/m-p/1153328#M7929</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-03-14T13:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error creating a map in a core host Application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map-in-a-core-host-application/m-p/1153368#M7932</link>
      <description>&lt;P&gt;&lt;SPAN&gt;In addition to &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/42133"&gt;@GKmieliauskas&lt;/a&gt;&amp;nbsp;, attempting to access any of the ArcGIS Pro UI elements or types in other assemblies in an&amp;nbsp;&lt;/SPAN&gt;&lt;EM&gt;ArcEngine-like&lt;/EM&gt;&lt;SPAN&gt;&amp;nbsp;fashion will crash the program. &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Details:&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/proconcepts-CoreHost" target="_self"&gt;&lt;SPAN&gt;Corehost Conceptual doc&lt;/SPAN&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 14:44:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/error-creating-a-map-in-a-core-host-application/m-p/1153368#M7932</guid>
      <dc:creator>Aashis</dc:creator>
      <dc:date>2022-03-14T14:44:53Z</dc:date>
    </item>
  </channel>
</rss>

