<?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: open aprx in standalone C# application in ArcGIS Pro SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1559061#M12301</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;are you sure this line:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Project project = await Project.OpenAsync(aprxFile);&lt;/LI-CODE&gt;&lt;P&gt;will work? Carlos already used something similar :&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Project project = Project.OpenAsync(aprxFile).Result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;without succes. I know with Result it would block until the task is completed, but in his case it seems to me he needs to wait for the result anyway.&lt;/P&gt;</description>
    <pubDate>Fri, 15 Nov 2024 06:01:10 GMT</pubDate>
    <dc:creator>RadekMandovec</dc:creator>
    <dc:date>2024-11-15T06:01:10Z</dc:date>
    <item>
      <title>open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1558174#M12293</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;I have converted an ArcObjects&amp;nbsp;SDK .NET application written in C# for creating PDF maps to an ArcGIS Pro add-in using the ArcGIS Pro SDK. Everything runs fine from within ArcGIS Pro but now I want to convert it to a standalone complied exe as the original is so I can run it from Windows Task Scheduler.&lt;/P&gt;&lt;P&gt;From my research, I understand that await QueuedTask.Run is only needed inside of Pro so I have been slowly removing these one function at a time in the order that each function runs.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Things work until I get to the function below which is supposed to open an aprx that I use as a template (has layout that I manipulate, layers loaded, etc.) and return a Project object which is used later in the code to retrieve a Map and a Layout.&lt;/P&gt;&lt;DIV&gt;public static Project GetProject()&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;string aprxFile = PATH_Aprx_template + "exhibit_map.aprx";&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;// Open the project&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;//Project project = Project.OpenAsync(aprxFile).Result;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;//Project project = Project.OpenAsync(aprxFile).GetAwaiter().GetResult();&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Project project = Project.OpenAsync(aprxFile);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;// Check if the project is null (failed to open)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if (project == null)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Console.WriteLine("Failed to open the project.");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return null;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return project;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;catch (Exception ex)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Console.WriteLine($"Error in GetProject: {ex.Message}");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return null;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;The project refuses to compile in Visual Studio with an error of "cannot implicitly convert type System.Threading.Tasks.Task&amp;lt;ArcGIS.Desktop.Core.Project&amp;gt; to ArcGIS.Desktop.Core.Project at line&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Project project = Project.OpenAsync(aprxFile);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;As you can see, I tried a couple of other things that are commented out but those didn't work either.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I am using ArcGIS Pro 3.3 and Visual Studio 2022.&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Can someone help me out?&lt;/DIV&gt;&lt;DIV&gt;Thanks,&lt;/DIV&gt;&lt;DIV&gt;Carlos&lt;/DIV&gt;</description>
      <pubDate>Wed, 13 Nov 2024 17:57:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1558174#M12293</guid>
      <dc:creator>CarlosPiccirillo2</dc:creator>
      <dc:date>2024-11-13T17:57:03Z</dc:date>
    </item>
    <item>
      <title>Re: open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1558744#M12299</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9199.html" target="_self"&gt;Project.OpenAsync&lt;/A&gt; returns Task&amp;lt;Project&amp;gt;. So, to assign result of&amp;nbsp;Project.OpenAsync to Project variable, you need to use await before&amp;nbsp;Project.OpenAsync. Your method could look like code below:&lt;/P&gt;
&lt;LI-CODE lang="c"&gt;public static async Task&amp;lt;Project&amp;gt; GetProject()
{
try
{
string aprxFile = PATH_Aprx_template + "exhibit_map.aprx";
 
// Open the project
Project project = await Project.OpenAsync(aprxFile);
 
// Check if the project is null (failed to open)
if (project == null)
{
Console.WriteLine("Failed to open the project.");
return null;
}
return project;
}
catch (Exception ex)
{
Console.WriteLine($"Error in GetProject: {ex.Message}");
return null;
}
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 17:16:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1558744#M12299</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-11-14T17:16:50Z</dc:date>
    </item>
    <item>
      <title>Re: open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1558754#M12300</link>
      <description>&lt;P&gt;Thanks for your help, I really appreciate it.&amp;nbsp; I will try this on Monday and post back.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2024 17:32:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1558754#M12300</guid>
      <dc:creator>CarlosPiccirillo2</dc:creator>
      <dc:date>2024-11-14T17:32:05Z</dc:date>
    </item>
    <item>
      <title>Re: open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1559061#M12301</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;are you sure this line:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Project project = await Project.OpenAsync(aprxFile);&lt;/LI-CODE&gt;&lt;P&gt;will work? Carlos already used something similar :&lt;/P&gt;&lt;LI-CODE lang="c"&gt;Project project = Project.OpenAsync(aprxFile).Result;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;without succes. I know with Result it would block until the task is completed, but in his case it seems to me he needs to wait for the result anyway.&lt;/P&gt;</description>
      <pubDate>Fri, 15 Nov 2024 06:01:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1559061#M12301</guid>
      <dc:creator>RadekMandovec</dc:creator>
      <dc:date>2024-11-15T06:01:10Z</dc:date>
    </item>
    <item>
      <title>Re: open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1559661#M12309</link>
      <description>&lt;P&gt;Hi guys, thanks for the replies. Unfortunately, the suggestions did not work. Below is the original function that works fine in my add-in but now that I am converting the code to a console standalone application, the&amp;nbsp;&lt;SPAN&gt;await QueuedTask.Run no longer applies. So I guess I need a different way to get a reference to the project.&lt;/SPAN&gt;&lt;/P&gt;&lt;DIV&gt;public static async Task&amp;lt;Project&amp;gt; GetProject()&lt;/DIV&gt;&lt;DIV&gt;{&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;try&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;string aprxFile = PATH_Aprx_template + "exhibit_map.aprx";&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;// Open the project&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Project project = await Project.OpenAsync(aprxFile);&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;// Check if the project is null (failed to open)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;if (project == null)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Console.WriteLine("Failed to open the project.");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return null;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return project;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;catch (Exception ex)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;//System.Windows.Forms.MessageBox.Show(ex.Message, "GetProject");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Console.WriteLine($"Error in GetProject: {ex.Message}");&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;return null;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;}&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;}&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Nov 2024 14:41:46 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1559661#M12309</guid>
      <dc:creator>CarlosPiccirillo2</dc:creator>
      <dc:date>2024-11-18T14:41:46Z</dc:date>
    </item>
    <item>
      <title>Re: open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1560792#M12313</link>
      <description>&lt;P&gt;Sorry&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/612984"&gt;@CarlosPiccirillo2&lt;/a&gt;&amp;nbsp;.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9187.html" target="_self"&gt;Project&lt;/A&gt; class belongs to&amp;nbsp;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/sdk/api-reference/topic9017.html" target="_blank"&gt;ArcGIS.Desktop.Core&lt;/A&gt;&amp;nbsp;workspace which is not accessible from CoreHost application.&amp;nbsp;ArcGIS.CoreHost and ArcGIS.Core assemblies are available from Corehost application only. More information &lt;A href="https://github.com/Esri/arcgis-pro-sdk/wiki/proconcepts-CoreHost" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2024 16:25:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1560792#M12313</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-11-20T16:25:30Z</dc:date>
    </item>
    <item>
      <title>Re: open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1560807#M12314</link>
      <description>&lt;P&gt;Thanks for the clarification. Do you know have I can get a reference to a Project (aprx) using ArcGIS.CoreHost or ArcGIS.Core?&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2024 16:52:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1560807#M12314</guid>
      <dc:creator>CarlosPiccirillo2</dc:creator>
      <dc:date>2024-11-20T16:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1560824#M12315</link>
      <description>&lt;P&gt;You could try to call python script with your workflow from CoreHost application or execute python script directly. We have similar situation with &lt;A href="https://community.esri.com/t5/arcgis-pro-sdk-questions/arcgis-desktop-core-geoprocessing-in-standalone/m-p/839925#M3751" target="_self"&gt;geoprocessing&lt;/A&gt; in CoreHost application. There is no way to call geoprocessing tool directly, but you can call it from python.&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2024 17:10:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1560824#M12315</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2024-11-20T17:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: open aprx in standalone C# application</title>
      <link>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1560841#M12316</link>
      <description>&lt;P&gt;The entire application is quite complex which is why I was trying to avoid going the Python route but It's starting to look like I will have to re-write the entire application in Python which I was hoping to avoid. Only have a year of experience in Python but over 15 years in C# which is why I ported over the old ArcMap (ArcObjects) code using C#.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Nov 2024 17:21:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-sdk-questions/open-aprx-in-standalone-c-application/m-p/1560841#M12316</guid>
      <dc:creator>CarlosPiccirillo2</dc:creator>
      <dc:date>2024-11-20T17:21:43Z</dc:date>
    </item>
  </channel>
</rss>

