Select to view content in your preferred language

Core host (stand alone .exe application): Possible to connect to and enterprise GDB and do a spatial query?

325
4
Jump to solution
08-19-2024 08:15 AM
AZendel
Frequent Contributor

I posted this last week

https://community.esri.com/t5/arcgis-pro-sdk-questions/standa-alone-exe-cannot-run-corehost-sample-q...

Over the weekend I wondered if it's even possible to do a spatial query overlay in a stand-alone "core host" app. This would be like doing a select by attributes in layer A, then a select by location for features in layer B and then loop through the results to read attribute values. It seems like a lot of Pro functionality requires you to build an add-in. This is obviously a must for tasks that require interaction with a map or the UI, but what about projects like mine that just need to do a spatial query? We could do this via ArcObjects with ArcMap, but we need to migrate our project to Pro. I understand that I'll need to check for Pro licenses (that part of my code already does). I want to avoid add-ins because every time you want to debug an add-in, you have to restart Pro, then load the project and then do all of the clicks to get your add-in to run. That's time consuming and it gets a bit frustrating.

0 Kudos
1 Solution

Accepted Solutions
GKmieliauskas
Esri Regular Contributor

I think that you use ArcGIS Pro 3.2. I have tested on ArcGIS Pro 3.2 and have the same results.

I had older samples and made testing with them.

Old version of sample works, newest don't. The difference is in csproj file.

Old version:

    <TargetFramework>net6.0-windows</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>

New version:

    <TargetFramework>net8.0-windows</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>

 

View solution in original post

0 Kudos
4 Replies
GKmieliauskas
Esri Regular Contributor

Hi,

Have you tried ArcGIS Pro Esri Community sample CoreHostGDB ? You can modify it for your requirements.

Change geodatabase constructor to one of the overloads for enterprise database:

public Geodatabase( 
   DatabaseConnectionProperties databaseConnectionProperties
)

or 

public Geodatabase( 
   DatabaseConnectionFile databaseConnectionFile
)

Add extra button which executes your workflow on selected table record. After testing you can delete all GUI if you don't need it.

To create Buffer use GeometryEngine.Instance.Buffer.

You can use all stuff from two libraries: ArcGIS.CoreHost.dll and ArcGIS.Core.dll

 

 

 

0 Kudos
AZendel
Frequent Contributor

Thanks for the suggestion. Unfortunately, I ran the solution without modifying anything. Then I navigated to a *file* geodatabase, clicked the Open button and got the MsgBox that read: "No tables or feature datasets read". I tried that with a FGDB on my C drive and on a network drive with the UNC path and the mapped drive "letter".

The exception that triggered the above occurred on the line that read:

using (Geodatabase gdb = new Geodatabase(
new FileGeodatabaseConnectionPath(new Uri(_gdbPath, UriKind.Absolute)))) {

The exception had this description: "External component has thrown an exception." Unfortunately, that doesn't help me troubleshoot much at all. Something more descriptive like "error checking out a license" would have been much more helpful!  And that was a very similar message that I got in my previous post on a very similar line that attempted to 'connect'/open the geodatabase. 

Thoughts?

0 Kudos
GKmieliauskas
Esri Regular Contributor

I think that you use ArcGIS Pro 3.2. I have tested on ArcGIS Pro 3.2 and have the same results.

I had older samples and made testing with them.

Old version of sample works, newest don't. The difference is in csproj file.

Old version:

    <TargetFramework>net6.0-windows</TargetFramework>
    <RuntimeIdentifier>win10-x64</RuntimeIdentifier>

New version:

    <TargetFramework>net8.0-windows</TargetFramework>
    <RuntimeIdentifier>win-x64</RuntimeIdentifier>

 

0 Kudos
AZendel
Frequent Contributor

That appears to have fixed it! It's listing the contents of a FGDB feature class. 

I'm on Pro 3.03 because our county's outdated version of ArcGIS server apparently doesn't play nice with anything > 3.0.x. Now to test this with our Enterprise GDB.

Thanks for your help!

0 Kudos