System.InvalidCastException on SubmitChange
Posted: Tue 12 Jul 2016 20:20
Hi - I am new to both SQLite and LINQ, but I'm evaluating the Devart LinqConnect product for developing a mid-size Visual Basic application using SQlite. I'm working in Visual Studio 2015. I've developed a small (almost trivial) test application that I can use to evaluate the product. It is a small DB with 2 tables - a master and a detail table. A single form displays the master-detail entries in the DB with a pair of data-bound datagrid controls. Works fine, except whenever I attempt to add a record to the details tables, I get an error when the SubmitChanges call is made.
I'm receiving the following exception when I perform a SubmitChanges on my small test database
Any ideas on what I need to change?
----------------------------------------------------------------------------
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Unable to cast object of type 'Devart.Data.Linq.Engine.ProviderType' to type 'Devart.Data.SQLite.Linq.Provider.SQLiteProviderType'.
Source=Devart.Data.SQLite.Linq
StackTrace:
at Devart.Data.SQLite.Linq.Provider.SQLiteDataProvider.ProcessParameterValue(DbParameter parameter, Type clrType, ProviderType providerType, Object value)
at Devart.Data.Linq.DataProvider.ApplyParameter(DbParameter parameter, String name, ParameterDirection direction, ProviderType providerType, Type clrType, Object parameterValue)
at Devart.Data.Linq.DataProvider.b(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.DataProvider.a(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.Engine.SubmitCommandBuilder.a(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.Engine.SubmitCommandBuilder.a(IObjectEntry A_0)
at Devart.Data.Linq.Engine.bz.c(IObjectEntry A_0)
at Devart.Data.Linq.Engine.bz.a(IObjectEntry[] A_0, ConflictMode A_1, a A_2)
at Devart.Data.Linq.Engine.bz.a(ConflictMode A_0)
at Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at Devart.Data.Linq.DataContext.SubmitChanges()
at LinqPlay2.DatabaseForm.SaveButton_Click(Object sender, EventArgs e) in C:\Users\Mike\documents\visual studio 2015\Projects\LinqPlay2\LinqPlay2\DatabaseForm.vb:line 185
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at LinqPlay2.MainForm.ShowForm(TF_DISPLAY_MODE mode) in C:\Users\Mike\documents\visual studio 2015\Projects\LinqPlay2\LinqPlay2\MainForm.vb:line 29
at LinqPlay2.MainForm.ManageFilesButton_Click(Object sender, EventArgs e) in C:\Users\Mike\documents\visual studio 2015\Projects\LinqPlay2\LinqPlay2\MainForm.vb:line 19
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at LinqPlay2.My.MyApplication.Main(String[] Args) in :line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
I'm receiving the following exception when I perform a SubmitChanges on my small test database
Any ideas on what I need to change?
----------------------------------------------------------------------------
System.InvalidCastException was unhandled
HResult=-2147467262
Message=Unable to cast object of type 'Devart.Data.Linq.Engine.ProviderType' to type 'Devart.Data.SQLite.Linq.Provider.SQLiteProviderType'.
Source=Devart.Data.SQLite.Linq
StackTrace:
at Devart.Data.SQLite.Linq.Provider.SQLiteDataProvider.ProcessParameterValue(DbParameter parameter, Type clrType, ProviderType providerType, Object value)
at Devart.Data.Linq.DataProvider.ApplyParameter(DbParameter parameter, String name, ParameterDirection direction, ProviderType providerType, Type clrType, Object parameterValue)
at Devart.Data.Linq.DataProvider.b(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.DataProvider.a(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.Engine.SubmitCommandBuilder.a(String A_0, IEnumerable`1 A_1, IEnumerable`1 A_2, Boolean A_3)
at Devart.Data.Linq.Engine.SubmitCommandBuilder.a(IObjectEntry A_0)
at Devart.Data.Linq.Engine.bz.c(IObjectEntry A_0)
at Devart.Data.Linq.Engine.bz.a(IObjectEntry[] A_0, ConflictMode A_1, a A_2)
at Devart.Data.Linq.Engine.bz.a(ConflictMode A_0)
at Devart.Data.Linq.DataContext.SubmitChanges(ConflictMode failureMode)
at Devart.Data.Linq.DataContext.SubmitChanges()
at LinqPlay2.DatabaseForm.SaveButton_Click(Object sender, EventArgs e) in C:\Users\Mike\documents\visual studio 2015\Projects\LinqPlay2\LinqPlay2\DatabaseForm.vb:line 185
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.RunDialog(Form form)
at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
at LinqPlay2.MainForm.ShowForm(TF_DISPLAY_MODE mode) in C:\Users\Mike\documents\visual studio 2015\Projects\LinqPlay2\LinqPlay2\MainForm.vb:line 29
at LinqPlay2.MainForm.ManageFilesButton_Click(Object sender, EventArgs e) in C:\Users\Mike\documents\visual studio 2015\Projects\LinqPlay2\LinqPlay2\MainForm.vb:line 19
at System.Windows.Forms.Control.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnClick(EventArgs e)
at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ButtonBase.WndProc(Message& m)
at System.Windows.Forms.Button.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
at LinqPlay2.My.MyApplication.Main(String[] Args) in :line 81
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: