Select to view content in your preferred language

Connecting to a Feature Service freezing Arc Pro

772
5
01-22-2020 01:45 PM
DavidLaMartina
Regular Contributor

I need to programmatically connect to a feature service. I'm doing this in the recommended way, creating a ServiceConnectionProperties object with the URL to the feature service, and then instantiating a Geodatabase object with those connection properties.

In certain cases, this is working fine. In other cases, certain feature service URLs are causing the program to hang indefinitely on the Geodatabase instantiation. Is this a known issue? I would think that even if the URL was invalid, or the connection required credentials I didn't provided, the attempt at instantiation would return with an error or throw an exception.

0 Kudos
5 Replies
RichRuh
Esri Regular Contributor

Hi David,

Do you have a short coding snippet you could share?

--Rich

DavidLaMartina
Regular Contributor

Yes, here's the code in question. The problem I'm describing happens when versionName is null (unversioned feature service). Basically, the URI is created correctly using the URL string passed in, and when the Geodatabase object is instantiated, everything hangs.

0 Kudos
RichRuh
Esri Regular Contributor

David,

I have some follow-up questions.

1) I assume you are using traditional versioning, and not branch versioning, right?

2) You're trying to run this as a Pro add-in, right?

I'm suspicious that your threading routines could be causing an issue.  These geodatabase routines are designed for use on the MCT.  In Pro, this means putting them inside QueuedTask.Run.  

--Rich

0 Kudos
DavidLaMartina
Regular Contributor

Thanks Rich - the threading routines were the issue, after all. I reorganized some of this code and the calling code so that the Geodatabase would be created inside a QueuedTask, and the hang stopped happening.

Strangely, this code did work fine with valid feature service URLs that I knew should work. For instance, if I connected to a Portal connection in Arc Pro, and then tried to connect to that feature service, the above code worked fine. If I tried to connect to an invalid URL, however, the program would hang.

0 Kudos
DavidLaMartina
Regular Contributor

Having fixed the Geodatabase instantiation to occur within a QueuedTask, I am encountering a new problem -

If I connect to an unfederated, non-Portal feature service, I get a couple of dialogs asking whether I want to proceed using an unsecure connection. In certain contexts, these dialogs make sense to the user (when they're actually configuring the feature service connection).

In other contexts, validation is happening behind the scenes, and the same dialogs pop up at times that will probably make much less sense to a user. For instance, when a Project is opening:

These pop up in the process of Geodatabase object instantiation using a ServiceConnectionProperties object. If the user selects No, the Geodatabase constructor throws an exception (which I've handled). If they select yes, instantiation proceeds normally.

Is there some way to actually "catch" these popups, so that we can at least present an additional dialog box of our own explaining the issue? I'm hoping to be able to call MessageBox.Show() when this happens, so we can tell the user which feature service connection needs their authority to proceed.

0 Kudos