<?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: CoreHost SpatialReference Issue in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1678399#M13384</link>
    <description>&lt;P&gt;Hi Selim,&lt;/P&gt;&lt;P&gt;So, I just go this working the other day.&amp;nbsp; We have an in-house built scheduler which I am not able to make changes to, and it only fails through the scheduler.&amp;nbsp; It turned out it was an issue with single apartment threading vs. multiple apartment threading in the scheduler.&amp;nbsp; Even though I have [STAThread] just above static void Main, I created a new single-threaded object and ran the main part of the code through it, and everything is working now.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; [STAThread]
 static void Main(string[] args)
 {
     //Perform CoreHost task
     //Call Host.Initialize before constructing any objects from ArcGIS.Core
     try
     {
         Console.WriteLine("Current Directory: " + Environment.CurrentDirectory);
         Console.WriteLine("Temp Environmental Variable: " + Environment.GetEnvironmentVariable("TEMP"));
         Console.WriteLine("UserName: " + Environment.UserName);

         Console.WriteLine("Getting the Application Runtime Directory");
         var loc = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();            
         Console.WriteLine("Application Runtime Directory: " + loc + "\n");

         //Resolve ArcGIS Pro assemblies.
         Console.WriteLine("Getting the Pro runtime directory");

         AppDomain currentDomain = AppDomain.CurrentDomain;
         currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveProAssemblyPath);

         //work-around due to multi-threading in jso
         var t = new Thread(()=&amp;gt; MainProcess(args));
         t.SetApartmentState(ApartmentState.STA);
         t.Start();
         t.Join();

     }
     catch (Exception e)
     {
         // Error (missing installation, no license, 64 bit mismatch, etc.)
         Console.WriteLine(string.Format("Initialization failed: {0}", e.Message));
         return;
     }
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 16 Jan 2026 16:52:21 GMT</pubDate>
    <dc:creator>GaryBilotta</dc:creator>
    <dc:date>2026-01-16T16:52:21Z</dc:date>
    <item>
      <title>CoreHost SpatialReference Issue</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1674114#M13326</link>
      <description>&lt;P&gt;I am working on my first CoreHost application and am running into issues deploying it.&amp;nbsp; The CoreHost application is a console application that I can debug and run successfully in Visual Studio 2022, and I can run it by hand outside of Visual Studio.&amp;nbsp; The issue is that this application will be run at night with other batch jobs, and when I attempt to have the scheduling software execute it, it fails- but it fails at an unexpected location. The code begins to execute and even opens a couple of feature classes, but when I try to do anything with spatial references, that is when it fails.&amp;nbsp; Both bits of code below fail.&amp;nbsp; If I were initializing incorrectly or didn't have the licensing configured properly, I would expect not to be able to open feature classes, but that part is successful.&amp;nbsp; I am running Pro 3.3.4.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;SpatialReference pSRWebMerc_3857 = SpatialReferences.WebMercator;
or
SpatialReference pSRWebMercAuxSph84_3857 = null;
SpatialReferenceBuilder spatialReferenceBuilder = new SpatialReferenceBuilder(3857);
pSRWebMercAuxSph84_3857 = spatialReferenceBuilder.ToSpatialReference();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the error:&amp;nbsp;&lt;/P&gt;&lt;P&gt;CoreInterop&lt;BR /&gt;at CGeometryInterop.CreateSpatialReferenceFromID_(CGeometryInterop*, Int32 wkid, Int32 vWkid, ISpatialReference** ppSR)&lt;BR /&gt;at CGeometryInterop.CreateSpatialReferenceFromID(CGeometryInterop*, Int32 wkID, Int32 wkvID, Void** outHandle)&lt;BR /&gt;at ArcGIS.Core.Internal.ISpatialReferenceIOP.CreateSpatialReferenceFromID(Int32 wkID, Int32 wkvID)&lt;BR /&gt;at ArcGIS.Core.Geometry.SpatialReferenceBuilder..ctor(Int32 wkid, Int32 verticalWkid, Boolean validateThread)&lt;BR /&gt;at ArcGIS.Core.Geometry.SpatialReferenceBuilder..ctor(Int32 wkid)&lt;BR /&gt;at UpdateFeatureClass.PerformCoreHostTask(String[] args) in \Dev\Repos\UpdateFeatureClass\clsUpdate.cs&lt;/P&gt;&lt;P&gt;Thoughts anyone??&lt;/P&gt;&lt;P&gt;Thank you!!!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Dec 2025 22:33:59 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1674114#M13326</guid>
      <dc:creator>GaryBilotta</dc:creator>
      <dc:date>2025-12-18T22:33:59Z</dc:date>
    </item>
    <item>
      <title>Re: CoreHost SpatialReference Issue</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1674334#M13328</link>
      <description>Doe your SYSTEM account running the job have access to 'in \Dev\Repos\UpdateFeatureClass\clsUpdate.cs'? these failures are usually permission related.&lt;BR /&gt;</description>
      <pubDate>Fri, 19 Dec 2025 18:50:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1674334#M13328</guid>
      <dc:creator>RichardDaniels</dc:creator>
      <dc:date>2025-12-19T18:50:44Z</dc:date>
    </item>
    <item>
      <title>Re: CoreHost SpatialReference Issue</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1674420#M13329</link>
      <description>&lt;P&gt;Yeah, the SYSTEM account does have access.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 19 Dec 2025 22:31:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1674420#M13329</guid>
      <dc:creator>GaryBilotta</dc:creator>
      <dc:date>2025-12-19T22:31:31Z</dc:date>
    </item>
    <item>
      <title>Re: CoreHost SpatialReference Issue</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1678302#M13383</link>
      <description>&lt;P&gt;Hi Gary,&lt;/P&gt;&lt;P&gt;Could you share how the Core and CoreHost DLLs are referenced in your solution?&lt;/P&gt;&lt;P&gt;Did you use the CoreHost template to get started?&lt;/P&gt;&lt;P&gt;What scheduling software are you using? Windows task scheduler or something else? Does it only fail when you run it through the scheduler or does it also fail when you run it interactively? If it only fails through the scheduler, could you share the parameters for the task, especially the Security options?&lt;/P&gt;&lt;P&gt;Sorry for the barrage of questions, trying to better understand your problem and the environment around it.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jan 2026 02:00:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1678302#M13383</guid>
      <dc:creator>SelimDissem</dc:creator>
      <dc:date>2026-01-16T02:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: CoreHost SpatialReference Issue</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1678399#M13384</link>
      <description>&lt;P&gt;Hi Selim,&lt;/P&gt;&lt;P&gt;So, I just go this working the other day.&amp;nbsp; We have an in-house built scheduler which I am not able to make changes to, and it only fails through the scheduler.&amp;nbsp; It turned out it was an issue with single apartment threading vs. multiple apartment threading in the scheduler.&amp;nbsp; Even though I have [STAThread] just above static void Main, I created a new single-threaded object and ran the main part of the code through it, and everything is working now.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt; [STAThread]
 static void Main(string[] args)
 {
     //Perform CoreHost task
     //Call Host.Initialize before constructing any objects from ArcGIS.Core
     try
     {
         Console.WriteLine("Current Directory: " + Environment.CurrentDirectory);
         Console.WriteLine("Temp Environmental Variable: " + Environment.GetEnvironmentVariable("TEMP"));
         Console.WriteLine("UserName: " + Environment.UserName);

         Console.WriteLine("Getting the Application Runtime Directory");
         var loc = System.Runtime.InteropServices.RuntimeEnvironment.GetRuntimeDirectory();            
         Console.WriteLine("Application Runtime Directory: " + loc + "\n");

         //Resolve ArcGIS Pro assemblies.
         Console.WriteLine("Getting the Pro runtime directory");

         AppDomain currentDomain = AppDomain.CurrentDomain;
         currentDomain.AssemblyResolve += new ResolveEventHandler(ResolveProAssemblyPath);

         //work-around due to multi-threading in jso
         var t = new Thread(()=&amp;gt; MainProcess(args));
         t.SetApartmentState(ApartmentState.STA);
         t.Start();
         t.Join();

     }
     catch (Exception e)
     {
         // Error (missing installation, no license, 64 bit mismatch, etc.)
         Console.WriteLine(string.Format("Initialization failed: {0}", e.Message));
         return;
     }
 }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Jan 2026 16:52:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/corehost-spatialreference-issue/m-p/1678399#M13384</guid>
      <dc:creator>GaryBilotta</dc:creator>
      <dc:date>2026-01-16T16:52:21Z</dc:date>
    </item>
  </channel>
</rss>

