Index: System.Data.SQLite/SQLiteLog.cs ================================================================== --- System.Data.SQLite/SQLiteLog.cs +++ System.Data.SQLite/SQLiteLog.cs @@ -190,10 +190,21 @@ EventArgs e ) { lock (syncRoot) { + // + // NOTE: Remove the default log event handler. + // + RemoveDefaultHandler(); + + // + // NOTE: Disable logging. If necessary, it can be re-enabled + // later by the Initialize method. + // + _enabled = false; + // // BUGBUG: This will cause serious problems if other AppDomains // have any open SQLite connections; however, there is // currently no way around this limitation. // @@ -209,10 +220,22 @@ if (rc != 0) throw new SQLiteException(rc, "Failed to shutdown logging."); } + + // + // BUGFIX: Make sure to reset the callback for next time. This + // must be done after it has been succesfully removed + // as logging callback by the SQLite core library as we + // cannot allow native code to refer to a delegate that + // has been garbage collected. + // + if (_callback != null) + { + _callback = null; + } // // NOTE: Remove the event handler for the DomainUnload event // that we added earlier. //