GetControllerDatasets throws exception

345
3
06-21-2018 09:43 AM
JohnReed1
New Contributor II

The following code throws an exception

if (table.IsControllerDatasetSupported())
                    {
                            IReadOnlyList<Dataset> controllerDatasets = table.GetControllerDatasets();

                     }

ArcGIS.Core.Data.GeodatabaseTopologyException: Network not found. ---> System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x80041970
   at ArcGIS.Core.Internal.IGeodatabaseIOP.Geodatabase_GetUtilityNetwork(IntPtr workspaceHandle, String name)
   at ArcGIS.Core.Data.GeodatabaseCore.OpenDatasetCore(String name)
   --- End of inner exception stack trace ---
   at ArcGIS.Core.Data.GeodatabaseCore.OpenDatasetCore(String name)
   at ArcGIS.Core.Data.Table.GetControllerDatasets()

This happens on 4 UN layers "Point Errors", "Line Errors", "Polygon Errors", and "Dirty Areas" The code runs fine on the other UN layers.

Is there something in addition to IsControllerDatasetSupported that I should be checking?

This is on 2.1.2

0 Kudos
3 Replies
RichRuh
Esri Regular Contributor

Hi John,

I can confirm that this is an issue.  We had intended GetControllerDatasets() to be used with user tables and not the system tables.  Could you tell us more about what you are trying to accomplish?

(At this point, our proposed solution is to have Table.IsControllerDatasetSupported() return false for these tables, which would fix the bug, but maybe not give you the behavior that you are looking for).

--Rich

0 Kudos
JohnReed1
New Contributor II

Hi Rich

I am just going through all the layers in the map and determining if they are UN layers or not. I am just using some code I found in a sample, or somewhere. Maybe there is a better way.

if (table.IsControllerDatasetSupported())
{
 try
 {
  IReadOnlyList<Dataset> controllerDatasets = table.GetControllerDatasets();
  foreach (Dataset controllerDataset in controllerDatasets)
  {
   if (controllerDataset is UtilityNetwork)
   {
    //Todo need to get this programmatically
    AssetTypeField = "ASSETTYPE";
    IsUtilityNetwork = true;
    break;
   }
  }
 }
 catch (Exception ex)
 {
  Logging.LogError(this, String.Format("Error getting UN information from Table {1} on Layer {0}",Name,TableName), ex);
 }
}

0 Kudos
RichRuh
Esri Regular Contributor

Well for what it's worth, the dirty area and error layers should only appear in a map as sublayers of a UtilityNetworkLayer.  So if you're searching through all the layers in order, you should be able to find a positive match and exit your loop before getting to the problematic tables.  If not, you can just catch the exception and continue.

0 Kudos