|Title:||Exception from logging initialization after library initialization|
|Last Modified:||2011-11-19 04:13:15|
|Version Found In:||126.96.36.199|
We use SQLite as an application file format, and the primary back-end code that deals with the database runs in a non-default AppDomain. One of our feature requires that we occasionally create an additional SQLiteConnection to a separate database while running in the default AppDomain. The non-default AppDomain use of SQLite will always occur *before* the default AppDomain use.
After upgrading from 188.8.131.52 to 184.108.40.206, we receive a SQLiteException with the message "Library used incorrectly" and "Failed to initialize logging". As far as I can tell, what's happening is logging initialization is skipped when we first create a connection (due to the IsDefaultAppDomain() check in SQLiteLog.Initialize()), and then logging tries to initialize when we subsequently create another connection in the default AppDomain, but sqlite3_config() fails because sqlite3_initialize() has already been called since the library is already in use.
I thought the Force_SQLite log environment variable might be usable as a workaround, but setting it will just cause logging to be initialized multiple times since SQLiteLog._callback is a static (and thus there each AppDomain has its own copy).
It seems to me that either logging init should be restricted to the first AppDomain to attempt it (instead of the default AppDomain every time) or it should be short-circuited if sqlite3_initialize() has already been called.
Note that we have our own private build of the library; we can modify it to work around this problem so a fix is not urgently needed.
mistachkin added on 2011-11-16 01:55:00 UTC:
mistachkin added on 2011-11-16 03:09:10 UTC:
anonymous claiming to be Jonathan Little added on 2011-11-19 04:13:15 UTC:
Confirmed it fixes the problem in our build, thanks!