
My requirements are pretty straightforward. WE have an AGO hosted feature server that is token secured, but I need to create a direct geodatabase connection using the .NET SDK via a Core Host application (note: this code works just fine through an add-in context). However, I'm getting the following error:
ArcGIS.Core.Data.GeodatabaseNotFoundOrOpenedException: Cannot find or open the specified geodatabase or data store. ---> ArcGIS.Core.Data.ServiceException: Authentication token required. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x8004021A
Which is strange, because I'm supplying the username and password. The SDK offers no way to set the Token. Also, even stranger, is that when I use the same code to create a connection to the same service from within an add-in, the username and password are not used, and the connection works. I'm guessing it's because the COM call is already authenticated since pro is open and I am logged in with my AGO credentials already. Any ideas?