ThinkGeo.com    |     Documentation    |     Premium Support

V14.3.0 - ESRI FileGeoDatabase - Exception if ActiveLayer Not Set

ThinkGeo Team,

If the ActiveLayer property is not set an exception is encountered on the Open.

Not an issue in V12.1.0.

Dennis

	oDatabaseTableItem.FileGeoDatabaseFeatureLayer                    = new FileGeoDatabaseFeatureLayer(TheFilePath);
	oDatabaseTableItem.FileGeoDatabaseFeatureLayer.Name               = oDatabaseTableItem.Name;
	oDatabaseTableItem.FileGeoDatabaseFeatureLayer.FeatureIdFieldName = "OBJECTID";

	oDatabaseTableItem.FileGeoDatabaseFeatureLayer.ActiveLayer        = oDatabaseTableItem.Name;

	oDatabaseTableItem.FileGeoDatabaseFeatureLayer.Open();

		Exception on Open if ActiveLayer not set



2025-03-13 19:24:14,022 ERROR OriStarFileDatabaseViewer - OriStarFileDatabaseViewer->GeneralMethods.PopulateDatabaseCollectionGdb:
FileGeoDatabaseFeatureLayer(C:\OriStar\xxx\OriStarVisionMapSuite\MapGeoDatabase\Airport.gdb)
Source=Esri.FileGDBAPI
TargetSite=Esri.FileGDB.Table OpenTable(System.String)
StackTrace=   at Esri.FileGDB.Geodatabase.OpenTable(String path)
   at GRU=.R0I=.VUI=(String pathName, String tableName)
   at GRU=.R0I=.VUI=()
   at GRU=.R0I=.KB8=()
   at ThinkGeo.Core.FileGeoDatabaseFeatureSource.OpenCore()
   at ThinkGeo.Core.FeatureSource.Open()
   at ThinkGeo.Core.FeatureLayer.OpenCore()
   at ThinkGeo.Core.Layer.Open()
   at OriStarFileDatabaseViewer.GeneralMethods.PopulateDatabaseCollectionGdb(String TheFile, String TheFilePath, String TheFileName, String TheFileTypeUpCase) in C:\OriStarMappingIncThinkGeoUI-V14.3.0Secondary\OriStarFileDatabaseViewer\TheGeneralMethods.cs:line 542
Message=The table was not found.
Esri.FileGDB.FileGDBException: The table was not found.
   at Esri.FileGDB.Geodatabase.OpenTable(String path)
   at GRU=.R0I=.VUI=(String pathName, String tableName)
   at GRU=.R0I=.VUI=()
   at GRU=.R0I=.KB8=()
   at ThinkGeo.Core.FileGeoDatabaseFeatureSource.OpenCore()
   at ThinkGeo.Core.FeatureSource.Open()
   at ThinkGeo.Core.FeatureLayer.OpenCore()
   at ThinkGeo.Core.Layer.Open()
   at OriStarFileDatabaseViewer.GeneralMethods.PopulateDatabaseCollectionGdb(String TheFile, String TheFilePath, String TheFileName, String TheFileTypeUpCase) in C:\OriStarMappingIncThinkGeoUI-V14.3.0Secondary\OriStarFileDatabaseViewer\TheGeneralMethods.cs:line 542

Hi Dennis,

The FileGeoDatabaseFeatureLayer in V12 is a wrapper of GdalFatureLayer, today in v14 you can still open an FileGeodatabase using Gdal Layer. For example, everything still works fine if replacing FileGeoDatabaseFeatureLayer with GdalFeatureLayer in HowDoI->DisplayFileGeoDatabase.xaml sample.

            //var fileGeoDatabaseFeatureLayer = new FileGeoDatabaseFeatureLayer(@"./Data/FileGeoDatabase/zoning.gdb")
            var fileGeoDatabaseFeatureLayer = new GdalFeatureLayer(@"./Data/FileGeoDatabase/zoning.gdb")
            {
                FeatureSource =
                {
                    ProjectionConverter = new ProjectionConverter(2276, 3857)
                },
                ActiveLayer = "zoning"
            };

            // Add the layer to the overlay we created earlier.
            fileGeoDatabaseOverlay.Layers.Add("Zoning", fileGeoDatabaseFeatureLayer);

            // Create an Area style on zoom level 1 and then apply it to all zoom levels up to 20.
            fileGeoDatabaseFeatureLayer.ZoomLevelSet.ZoomLevel01.DefaultAreaStyle = new AreaStyle(GeoPens.Black, new GeoSolidBrush(new GeoColor(50, GeoColors.Blue)));
            fileGeoDatabaseFeatureLayer.ZoomLevelSet.ZoomLevel01.ApplyUntilZoomLevel = ApplyUntilZoomLevel.Level20;

About the specific question regarding ActiveLayer, we throw the exception on purpose to remind the user to set up ActiveLayer to avoid the confusion. This is not required for GdalFeatureLayer just like before.

I see you asked some other FileGeoDatabase questions. Some exception might be thrown on purpose and some others might be bugs. If you don’t want to go back to GdalFeatureLayer, can you provide the test data to help us locate the issue? You can either upload here or send to support@thinkgeo.com

Thanks,
Ben

Ben,

I’m zipping the layers and will email shortly.

Dennis

Hi Dennis,

We received your test data. I will use them to help recreating/testing the other FileGeoDatabase related issues you created.

For this particular one, it’s throwing the exception by design if ActiveLayer is not set. Please try/catch the exception and handle it based on your scenario.

Thanks,
Ben

hi Ben,

I decided to simply set the ActiveLayer and that solves the situation.

Thanks,
Dennis

Sounds good, Dennis. :+1: