hi Ethan,
I have implemented your suggestion to Close FeatureLayer s when the application is shutting down.
Application is running MapSuite V10.5.
Under Windows-10 it works in both debug mode and when running directly from the applications’ executable.
However, my target machines are Windows-7 and when running directly from the applications’ executable MapSuite encounters an Unhandled Exception upon FeatureLayer.Close. There are actually three different scenarios under which this occurs.
First…upon application startup nine GDB layers are instantiated. Each one in turn is Opened and then Closed simply to make sure the layers can be opened/closed. Under Windows-10 this works fine. However, under Windows-7 only the first layer may be opened and then closed. The second layer may be opened, but encounter the Unhandled Exception when attempting to Close. The following is the exception:
Log Name: Application
Source: .NET Runtime
Date: 8/23/2019 7:02:43 PM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: name
Description:
Application: application.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at <Module>.FileGDBAPI.Geodatabase.{ctor}(FileGDBAPI.Geodatabase*)
at Esri.FileGDB.Geodatabase..ctor()
at Esri.FileGDB.Geodatabase.Open(System.String)
at FileGdbApiWrapper.FileGdbApiWrapper.GetGeodatabase(System.String)
at FileGdbApiWrapper.FileGdbApiWrapper.GetTableNames(System.String)
Exception Info: System.Reflection.TargetInvocationException
at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
at ThinkGeo.MapSuite.Layers.FileGeoDatabaseFeatureSource.GetTableNames(System.String)
at ThinkGeo.MapSuite.Layers.FileGeoDatabaseFeatureLayer.GetTableNames(System.String)
at OriStarVisionMapSuite.clsMapLayerItemCollection.PrepareLayerFromDatabaseGdb(OriStarVisionMapSuite.clsMapLayerItem ByRef)
at OriStarVisionMapSuite.clsMapLayerItemCollection.PrepareLayerFromDatabase(OriStarVisionMapSuite.clsMapLayerItem ByRef)
at OriStarVisionMapSuite.clsMapLayerItemCollection.Load(OriStarTools.OleDb ByRef)
Second…If only one GDB layer is instantiated and only Opened at application start the following exception occurs when the application is shutdown and an attempt to Close the single GDB layer:
Log Name: Application
Source: .NET Runtime
Date: 8/23/2019 7:34:32 PM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: name
Description:
Application: application.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at <Module>.FileGDBAPI.Geodatabase.CloseTable(FileGDBAPI.Geodatabase*, FileGDBAPI.Table*)
at Esri.FileGDB.Table.Shutdown()
at Esri.FileGDB.Table.Dispose(Boolean)
at Esri.FileGDB.Table.Finalize()
Third…All nine GDB layers are instantiated and just opened at application startup. All nine layers are rendered properly. When the application is shutdown and an attempt to Close GDB layers the following occurs:
Log Name: Application
Source: .NET Runtime
Date: 8/23/2019 7:59:15 PM
Event ID: 1026
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: name
Description:
Application: application.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException
at <Module>.FileGDBAPI.Geodatabase.CloseTable(FileGDBAPI.Geodatabase*, FileGDBAPI.Table*)
at Esri.FileGDB.Table.Close()
at FileGdbApiWrapper.FileGdbApiWrapper.DisposeGeodatatable(System.String, System.String)
at FileGdbApiWrapper.FileGdbApiWrapper.Close()
Exception Info: System.Reflection.TargetInvocationException
at System.RuntimeMethodHandle.InvokeMethod(System.Object, System.Object[], System.Signature, Boolean)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(System.Object, System.Object[], System.Object[])
at System.Reflection.RuntimeMethodInfo.Invoke(System.Object, System.Reflection.BindingFlags, System.Reflection.Binder, System.Object[], System.Globalization.CultureInfo)
at ThinkGeo.MapSuite.Layers.FileGeoDatabaseFeatureSource.CloseCore()
at ThinkGeo.MapSuite.Layers.FeatureSource.Close()
at ThinkGeo.MapSuite.Layers.FeatureLayer.CloseCore()
at ThinkGeo.MapSuite.Layers.Layer.Close()
at OriStarVisionMapSuite.MapFunctions.FeatureLayerClose()
at OriStarVisionMapSuite.ucMap.CloseMap()
at ViewOfChicago.MainWindow.Window_Closing(System.Object, System.ComponentModel.CancelEventArgs)
at System.Windows.Window.OnClosing(System.ComponentModel.CancelEventArgs)
at System.Windows.Window.WmClose()
at System.Windows.Window.WindowFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at System.Windows.Interop.HwndSource.PublicHooksFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
Regards,
Dennis