Insert operation leads to exception on Windows when installed using msi
(1) By anonymous on 2021-10-29 12:51:10 [source]
The msi installed exe is unable to insert data on sqlite on OS build 19042.1288+ with below exception call stack
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Data.SQLite.SQLiteException at System.Data.SQLite.SQLite3.Reset(System.Data.SQLite.SQLiteStatement) at System.Data.SQLite.SQLite3.Step(System.Data.SQLite.SQLiteStatement) at System.Data.SQLite.SQLiteDataReader.NextResult() at System.Data.SQLite.SQLiteDataReader..ctor(System.Data.SQLite.SQLiteCommand, System.Data.CommandBehavior) at System.Data.SQLite.SQLiteCommand.ExecuteReader(System.Data.CommandBehavior) at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery(System.Data.CommandBehavior) at CromptonConfigurator.CustomMeter.CUA_SaveClick(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.Controls.Primitives.ButtonBase.OnClick() at System.Windows.Controls.Button.OnClick() at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(System.Windows.Input.MouseButtonEventArgs) 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.ReRaiseEventAs(System.Windows.DependencyObject, System.Windows.RoutedEventArgs, System.Windows.RoutedEvent) at System.Windows.UIElement.OnMouseUpThunk(System.Object, System.Windows.Input.MouseButtonEventArgs) 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.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.HwndMouseInputProvider.ReportInput(IntPtr, System.Windows.Input.InputMode, Int32, System.Windows.Input.RawMouseActions, Int32, Int32, Int32) at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr, MS.Internal.Interop.WindowMessage, IntPtr, IntPtr, Boolean ByRef) at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef) at MS.Win32.HwndSubclass.DispatcherCallbackOperation(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 MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr) at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef) at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame) at System.Windows.Application.RunDispatcher(System.Object) at System.Windows.Application.RunInternal(System.Windows.Window)
But is able to insert when ran in administrative mode. How to resolve this issue?
(2) By Larry Brasfield (larrybr) on 2021-10-29 13:05:05 in reply to 1 [link] [source]
Your application, (identity of which remains a mystery), is clearly doing something which requires permission(s) not given to some ordinary users.
The SQLite project does not publish any application which uses either ".msi" installation or exception-style error handling. Your issue is with the mystery application and should be taken up with its vendor, author or publisher. Or you need to install it differently. (I can only guess on this.)
(3) By Stephan Beal (stephan) on 2021-10-29 13:08:04 in reply to 2 [link] [source]
The SQLite project does not publish any application which uses either ".msi" installation or exception-style error handling.
That particular API is maintained under this project's umbrella:
As you say, though, the OP's problem is certainly one of trying to write somewhere where a non-admin user is not permitted.
(4) By anonymous on 2021-11-05 07:59:32 in reply to 3 [link] [source]
Basically I pack the db file in the installer as a content file, and the application reads and writes to this file. So how do you suggest I package this in the installer, so that its not restricted to admin permission
Below is the properties for this content file
exclude - false
FOlder - application folder
hidden - true
keyOutput - none
outputs - outputs
packageAs - vsdpaDefault
permanent - false
register - vsdrpDoNotRegister
SharedLegacy - false
System - true
Transitive - false
vital - true
I have used the "setup project" project type from VS Profession 2019 package
Also one thing I would like to point out is that the application runs normally in OS build - 19042.1237, but is asking for administrator permission in 19042.1288 +
(5) By Larry Brasfield (larrybr) on 2021-11-05 13:58:39 in reply to 4 [link] [source]
You need to arrange that, once installed, your application can be used by those for whom it is intended to be used. This means that the DB file will need to have permissions consistent with modification by those users.
How to achieve that using your preferred installer software is off-topic here. Whether the solution is to use installer features or some kind of post-install fixup script, discussion of it should happen elsewhere. I expect there are fora dedicated to your installer where your problem would be readily solved and topical.
You might also consider having the application itself create the DB file when it does not yet exist.
(6) By anonymous on 2021-11-05 19:23:44 in reply to 5 [link] [source]
Had to rule out application creating the DB file as there is lot of data which needs to be preloaded, and do it on the first time application launch might slow down the application launch and also increase the code management. So packaging it with the required metadata sets. Sure will check in another forum. Just wanted to check if SQLite has any such permission restrictions. Thanks for the support.
(7) By Simon Slavin (slavin) on 2021-11-05 22:09:15 in reply to 6 [link] [source]
It is normal to include a copy of the 'starting' database inside the program. This can be a database with schema and possibly data too, and you will probably have run VACUUM on it just before including it in your project.
On startup, the program checks to see if a database file exists in the 'working' folder where it has read/write/delete permissions. If not, it duplicates the one from its own package to that folder. Then it opens that one.
This is the fastest way to get a pre-made copy of schema+data to your working folder. However, it is platform-dependent since you have to know how each platform handles file creation/protection.