/////////////////////////////////////////////////////////////////////// #if !PLATFORM_COMPACTFRAMEWORK /// <summary> /// Handles the AppDomain being unloaded. /// </summary> /// <param name="sender">Should be null.</param> /// <param name="e">The data associated with this event.</param> private static void DomainUnload( object sender, 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; #if !USE_INTEROP_DLL || !INTEROP_LOG // // BUGBUG: This will cause serious problems if other AppDomains // have any open SQLite connections; however, there is // currently no way around this limitation. // if (_sql != null) { SQLiteErrorCode rc = _sql.Shutdown(); if (rc != SQLiteErrorCode.Ok) { throw new SQLiteException(rc, "Failed to shutdown interface."); } rc = _sql.SetLogCallback(null); if (rc != SQLiteErrorCode.Ok) { 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; } #endif // // NOTE: Remove the event handler for the DomainUnload event // that we added earlier. // if (_domainUnload != null) { AppDomain.CurrentDomain.DomainUnload -= _domainUnload; _domainUnload = null; } } }