System.Data.SQLite slow connection for non-admin users

I have a .NET 4 application (in mixed mode) with System.Data.Sqlite (1.0.82) to access a database on an encrypted database.

When I install the application in "c: \ program files \ myfolder", the connection to the sqlite database file is slow. The log files show that this is a sqlite join statement that lingers for a few seconds.

The problem does not occur if I do the following:

  • Run the application with administrator rights
  • Install any other place except c: \ program files \
  • Install the application in c: \ program files \, but move the database to another folder.

I do not know what could be the reason for this ...

+6
source share
2 answers

If the DB file is in the application directory, most likely, UAC transfers it to the directory "... appdata \ Local \ VirtualStore \ Program Files". Best practice is to create your own appdata \ MyApp folder and copy the untouched database from the c: \ program files \ MyApp folder.

+5
source

This helps to open the database in read-only mode. (In any case, you should only store read-only files in a folder with program files.)

Just add ";Read Only=True" to the connection string.

 private const string CONN_TEMPL = "Data Source={0};Version=3;Read Only=True"; var conn = new SQLiteConnection( String.Format(CultureInfo.InvariantCulture, CONN_TEMPL, databasePath) ); 
+1
source

Source: https://habr.com/ru/post/927813/


All Articles