I am encountering an exception when I try to retrieve a read only list of RasterDatasetDefinitions from a file geodatabase using the GetDefinitions method. The file geodatabase being accessed contains a feature class, a mosaic dataset and a raster dataset.
The GetDefinitions method behaves when retrieving feature classes and tables with no problem.
IReadOnlyList<FeatureClassDefinition> featureClassDefinitions = geodatabase.GetDefinitions<FeatureClassDefinition>();
IReadOnlyList<TableDefinition> TableDefinitions = geodatabase.GetDefinitions<TableDefinition>();
The following statement throws the error:
IReadOnlyList<RasterDatasetDefinition> rasterDatasetDefinitions = geodatabase.GetDefinitions<RasterDatasetDefinition>();
My post did not accept all of the content I had included. I had attached a screen shot showing the output window showing I could evaluate the name and type of the feature class and the table requests.
Any insight regarding this would be appreciated.
Thanks for your time.
Same problem here, with a variety of 10.x file geodatabases - even with a fresh and completely empty 10.x .gdb!
The singular version also fails with the same exception, regardless of whether the dataset exists or not:
RasterDatasetDefinition rddef = gdb.GetDefinition<RasterDatasetDefinition>("Aerial");
VS Output window shows:
Exception thrown at 0x00007FFF655C50D8 in MFCApplication.exe: Microsoft C++ exception: std::out_of_range at memory location 0x000000E6941FE440.
Exception thrown: 'System.Runtime.InteropServices.SEHException' in ArcGIS.Core.dll
An exception of type 'System.Runtime.InteropServices.SEHException' occurred in ArcGIS.Core.dll but was not handled in user code
External component has thrown an exception.
Strange thing is, GetDefinitions<RasterDatasetDefinition>() does seem to work with a 9.x .gdb, which might be a clue for the devs.
We have encountered another issue with RasterDatasetDefinition, and I'm not sure if it will turn out to be related to the above issue or not.
We had some code that opened a RasterDataset to fetch its RasterDatasetDefinition, as a sort of workaround for the above. It appeared to work correctly, and we got valid Definitions from it. However, some calls later, we would get a crash in code that previously worked fine in smaller tests. There was a _purecall() error occurring during calls to OpenDataset<RasterDataset>(), CreateFullRaster() and some others. Most of the cases also had ArcGIS.Core.Internal.Interop.SweepReleaseList() in the stack.
We spent quite some time making sure we are handling object lifetimes and Dispose() correctly, but in the end what worked is to never use RasterDatasetDefinition, at all. I guess something about it corrupts the data that SweepReleaseList() uses, hence causing the _purecall() crashes.
Example call stack:
vcruntime140.dll!_purecall() Line 29 C++
[Managed to Native Transition]
ArcGIS.Core.dll!ArcGIS.Core.CoreObjectsBase.Attach(System.IntPtr handle) Unknown
ArcGIS.Core.dll!ArcGIS.Core.Data.Dataset.Dataset(System.IntPtr datasetHandle, ArcGIS.Core.Data.Datastore datastore) Unknown
ArcGIS.Core.dll!ArcGIS.Core.Data.GeodatabaseCore.OpenDatasetCore<ArcGIS.Core.Data.Raster.RasterDataset>(string name) Unknown
It would appear that my previous guesswork was incorrect, and actually it is the Dispose of a RasterBand that causes the fatal exit. I've whittled it down to:
// Using GetBand() works, but after it's Disposed the next API call or Dispose results in:
// Unhandled exception at 0x00007FFA15C4E55E (ucrtbase.dll) in JustPro.exe: Fatal program exit requested.
using (Geodatabase gdb = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri("d:\\_GDB Maps\\Eng_Wal.gdb"))))
using (RasterDataset rd = gdb.OpenDataset<RasterDataset>("DSM"))
using (RasterBand rb = rd.GetBand(0))
rd.CreateFullRaster(); // <-- e.g. here
} // <-- or here, if the previous line is removed