Behavior described below was tested in ArcGIS Pro 2.6.3 and 2.8.2 and works the same in both. Using .net framework 4.8.
I have this code snippet using the ArcGIS Pro SDK CoreHost that is run through AutoCAD 2021 using the netload command. This first example connects to an Enterprise Geodatabase using an sde connection to get a list of versions and works every time the command is executed. This is part of a bigger application that reads data from an SDE Version (selected by the user) and creates entities in the AutoCAD drawing.
[STAThread]
//AutoCAD .net runtime command
[CommandMethod("AGTEST")]
public void Execute()
{
Host.Initialize();
var sdeconn = new DatabaseConnectionFile(new Uri("pathto.sde file"));
var gdb = new Geodatabase(sdeconn);
if (gdb.IsVersioningSupported())
{
var versionm = gdb.GetVersionManager();
var versions = versionm.GetVersionNames().OrderBy(p => p).ToList();
}
}I'm currently attempting to move to a Utility Network and updating the code to use ServiceConnectionProperties to instantiate the GeoDatabase.
[STAThread]
//AutoCAD .net runtime command
[CommandMethod("AGTEST")]
public void Execute()
{
Host.Initialize();
var scp = new ServiceConnectionProperties(new Uri("https://myportal.mydomain.com/arcgis/rest/services/UN/Water_Distribution_Utility_Network/FeatureServer"));
var gdb = new Geodatabase(scp);
if (gdb.IsVersioningSupported())
{
var versionm = gdb.GetVersionManager();
var versions = versionm.GetVersionNames().OrderBy(p => p).ToList();
}
}The first time this code is ran it works as expected. Sometimes even subsequent executions work but eventually an exception will be thrown on line 12. The error reported is ArcGIS.Core.Data.GeodatabaseGeneralException HResult=0x80131500 Message=The application is not licensed to edit this type of data.
Since it's service request I'm able to see what is happening with Fiddler and at some point the token stops being supplied in the requests and this is what triggers the error.
I would appreciate any advice on how to make this work.
Thanks, Jimmy