Sqlite crashes on SqliteConnecion
I have an application that uses Sqlite. I has been working perfectly for a couple of year. I'm using Nuget System.Data.SQLite.Core 1.0.113.7 I tried to run it and i get this exception.
System.AccessViolationException HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source= StackTrace:
The exception occurs in the
public static string DbFile
{
get { return Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\Foo\\Bar" + "\\Order.db"; }
}
public static SQLiteConnection OrderDbConnection()
{
try
{
var db = $"Data Source={DbFile};Version=3;";
return new SQLiteConnection(db);
}
catch (Exception ex)
{
var m = ex.Message;
throw;
}
}
on the line return new SQLiteConnection(db);
I'm using
Visual Studio 2017 version 15.9.35
.NET Framework 4.7.2
Edition Windows 10 Pro
Version 20H2
Installed on 2020-11-05
OS build 19042.928
Experience Windows Feature Experience Pack 120.2212.551.0
I just tried the application on windows 10 version 1909 and there it works!
Has anyone any idea on what could be wrong?
EDIT: Add Exception from Event Viewer
Application: DCMatrix.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.AccessViolationException at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(System.Data.SQLite.SQLiteConfigOpsEnum) at System.Data.SQLite.SQLite3.StaticIsInitialized() at System.Data.SQLite.SQLiteLog.Initialize(System.String) at System.Data.SQLite.SQLiteConnection..ctor(System.String, Boolean)
at System.Data.SQLite.SQLiteConnection..ctor(System.String) at AbortedOrderDatabase.SqLiteBaseRepository.OrderDbConnection() at AbortedOrderDatabase.SqLiteOrderRepository.IsOrderDone(System.String) at DCMatrix.Workflow.IsOrderDone(System.String) at DCMatrix.Workflow.GetOrder(System.String, Boolean ByRef, Boolean ByRef) at DCMatrix.ViewMainWindow.DoLoadDataCommand() at DCMatrix.ViewMainWindow.<get_LoadDataCommand>b__21_1(System.Object)
at DCMatrix.RelayCommand.Execute(System.Object) at System.Windows.Input.CommandManager.TranslateInput(System.Windows.IInputElement, System.Windows.Input.InputEventArgs) at System.Windows.UIElement.OnKeyDownThunk(System.Object, System.Windows.Input.KeyEventArgs) at System.Windows.Input.KeyEventArgs.InvokeEventHandler(System.Delegate, System.Object) at System.Windows.RoutedEventArgs.InvokeHandler(System.Delegate, System.Object) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(System.Object, System.Windows.RoutedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(System.Object, System.Windows.RoutedEventArgs, Boolean) at System.Windows.UIElement.RaiseEventImpl(System.Windows.DependencyObject, System.Windows.RoutedEventArgs) at System.Windows.UIElement.RaiseTrustedEvent(System.Windows.RoutedEventArgs) at System.Windows.UIElement.RaiseEvent(System.Windows.RoutedEventArgs, Boolean) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(System.Windows.Input.InputEventArgs) at System.Windows.Input.InputProviderSite.ReportInput(System.Windows.Input.InputReport) at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawKeyboardActions, Int32, Boolean, Boolean, Int32) at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(System.Windows.Interop.MSG ByRef, Boolean ByRef) at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(System.Windows.Interop.MSG ByRef, System.Windows.Input.ModifierKeys) at System.Windows.Interop.HwndSource.OnPreprocessMessage(System.Object)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32) at System.Windows.Threading.Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority, System.Delegate, System.Object) at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(System.Windows.Interop.MSG ByRef, Boolean ByRef) at System.Windows.Interop.HwndSource+WeakEventPreprocessMessage.OnPreprocessMessage(System.Windows.Interop.MSG ByRef, Boolean ByRef) at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(System.Windows.Interop.MSG ByRef) at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) at System.Windows.Threading.Dispatcher.PushFrame(System.Windows.Threading.DispatcherFrame) at System.Windows.Application.RunDispatcher(System.Object) at System.Windows.Application.RunInternal(System.Windows.Window) at System.Windows.Application.Run(System.Windows.Window) at System.Windows.Application.Run() at DCMatrix.App.Main()
EDIT 2 Exception and Stack Trace
System.AccessViolationException HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source= StackTrace:" at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op) at System.Data.SQLite.SQLite3.StaticIsInitialized() at System.Data.SQLite.SQLiteLog.Initialize(String className) at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework) at System.Data.SQLite.SQLiteConnection..ctor(String connectionString)
at AbortedOrderDatabase.SqLiteBaseRepository.OrderDbConnection() in E:\Users\ame\source\repos\Seco Tools\DCMatrix\OrderDatabase\SqLiteBaseRepository.cs:line 23"
EDIT 3 Enabled Native Code Debugging
Exception thrown at 0x776388E3 (ntdll.dll) in DCMatrix.exe: 0xC0000005: Access violation writing location 0x0044005C. occurred
System.AccessViolationException HResult=0x80004003
Message=Attempted to read or write protected memory. This is often an indication that other memory is corrupt. Source= StackTrace:" at System.Data.SQLite.UnsafeNativeMethods.sqlite3_config_none(SQLiteConfigOpsEnum op) at System.Data.SQLite.SQLite3.StaticIsInitialized() at System.Data.SQLite.SQLiteLog.Initialize(String className) at System.Data.SQLite.SQLiteConnection..ctor(String connectionString, Boolean parseViaFramework) at System.Data.SQLite.SQLiteConnection..ctor(String connectionString)
at AbortedOrderDatabase.SqLiteBaseRepository.OrderDbConnection() in E:\Users\ame\source\repos\Seco Tools\DCMatrix\OrderDatabase\SqLiteBaseRepository.cs:line 23 at AbortedOrderDatabase.SqLiteOrderRepository.IsOrderDone(String mo) in E:\Users\ame\source\repos\Seco Tools\DCMatrix\OrderDatabase\SqLiteOrderRepository.cs:line 57 at DCMatrix.Workflow.IsOrderDone(String mo) in E:\Users\ame\source\repos\Seco Tools\DCMatrix\DCMarker\Workflow.cs:line 977 at DCMatrix.Workflow.GetOrder(String tvnr, Boolean& isAbortedOrder, Boolean& isOrderDone) in E:\Users\ame\source\repos\Seco Tools\DCMatrix\DCMarker\Workflow.cs:line 920 at DCMatrix.ViewMainWindow.DoLoadDataCommand() in E:\Users\ame\source\repos\Seco Tools\DCMatrix\DCMarker\CommandMainWindow.cs:line 244 at DCMatrix.ViewMainWindow.<get_LoadDataCommand>b__21_1(Object p) in E:\Users\ame\source\repos\Seco Tools\DCMatrix\DCMarker\CommandMainWindow.cs:line 122 at DCMatrix.RelayCommand.Execute(Object parameter) in E:\Users\ame\source\repos\Seco Tools\DCMatrix\DCMarker\RelayCommand.cs:line 34 at System.Windows.Input.CommandManager.TranslateInput(IInputElement targetElement, InputEventArgs inputEventArgs) at System.Windows.UIElement.OnKeyDownThunk(Object sender, KeyEventArgs e) at System.Windows.Input.KeyEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget) at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args) at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted) at System.Windows.Input.InputManager.ProcessStagingArea() at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport) at System.Windows.Interop.HwndKeyboardInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey) at System.Windows.Interop.HwndKeyboardInputProvider.ProcessKeyAction(MSG& msg, Boolean& handled) at System.Windows.Interop.HwndSource.CriticalTranslateAccelerator(MSG& msg, ModifierKeys modifiers) at System.Windows.Interop.HwndSource.OnPreprocessMessage(Object param)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler) at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs) at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg) at System.Windows.Interop.HwndSource.OnPreprocessMessageThunk(MSG& msg, Boolean& handled) at System.Windows.Interop.HwndSource.WeakEventPreprocessMessage.OnPreprocessMessage(MSG& msg, Boolean& handled) at System.Windows.Interop.ThreadMessageEventHandler.Invoke(MSG& msg, Boolean& handled) at System.Windows.Interop.ComponentDispatcherThread.RaiseThreadMessage(MSG& msg) at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame) at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Application.RunDispatcher(Object ignore) at System.Windows.Application.RunInternal(Window window) at System.Windows.Application.Run(Window window) at System.Windows.Application.Run() at DCMatrix.App.Main()"
User contributions licensed under CC BY-SA 3.0