System.Data.SQLite
View Ticket
Not logged in
Ticket UUID: ca5a37156166603cd97f8273f5ce08a6e2240ff9
Title: EntryPointNotFoundException in System.Data.SQLite after displaying FolderBrowserDialog in 64 bit application
Status: Closed Type: Incident
Severity: Important Priority: Medium
Subsystem: Integration_Via_PInvoke Resolution: External_Bug
Last Modified: 2014-05-12 18:30:16
Version Found In: 1.0.92.0
User Comments:
anonymous added on 2014-05-09 01:57:25: (text/x-fossil-plain)
In a 64-bit application an exception is thrown when trying to open a connection to a database with "Foriegn Keys=True" but only after FolderBrowserDialog is displayed. Example program:

public Form1()
{
    InitializeComponent();

    // Exception below if this is displayed
    using (var diag = new FolderBrowserDialog())
    {
        diag.ShowDialog(this);
    }

    var conn = new SQLiteConnection("data source=':memory:'");
    conn.Open(); // Works fine
    conn.Close();

    // No exception below if displayed here instead
    //using (var diag = new FolderBrowserDialog())
    //{
    //    diag.ShowDialog(this);
    //}

    conn = new SQLiteConnection("data source=':memory:';foreign keys=True");
    conn.Open(); // EntryPointNotFoundException thrown here
    conn.Close();
}

Further details:
[http://stackoverflow.com/q/23555146/1730559]

mistachkin added on 2014-05-09 17:35:10: (text/x-fossil-plain)
This sounds like perhaps the PATH environment variable is being changed prior to
the System.Data.SQLite managed assembly loading the SQLite.Interop.dll and it may
be picking up an outdated version that lacks some of the required exports.

anonymous added on 2014-05-10 16:26:48: (text/x-fossil-plain)
The machine is a new development machine which has only ever had versions 1.0.91 and 1.0.92 installed.  I did have 1.0.91 installed in the GAC however uninstalled to make sure that wasn't the problem. Currently using 1.0.92.0 obtained through Nuget.

anonymous added on 2014-05-10 16:38:33: (text/x-fossil-plain)
And, in case if you didn't look at the stackoverflow question, this happens in the case of using the managed + interop dll (in x64 folder or same folder as the System.Data.SQLite.dll) and also in the case of using the "bundle" mixed mode x64 System.Data.SQLite.dll with no interop.

anonymous added on 2014-05-12 08:07:45: (text/x-fossil-plain)
I have looked at this issue further and found the cause of the problem.  There is a shell extension installed on my computer which uses version 1.0.80.0 of System.Data.SQLite.  Displaying any of the common dialogs which includes explorer will cause the old version of the assembly and native interop library to be loaded into the application's AppDomain.  I'm not sure if there's any way to make sure that the System.Data.SQLite assembly is loading / using the correct version of the native library or at least check the path of the loaded library against the path of the correct interop library.