Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite.Interop unable to delete file on clean of solution

I'm using the Nuget package System.Data.SQLite in an MVC web application. There seems to be lock issue when I try to clean the solution and rebuild. The error message I get is: Unable to delete file "bin\x64\SQLite.Interop.dll". Access to the path '\bin\x64\SQLite.Interop.dll' is denied.

I'm thinking that the database is either still open or that the .dll is still in use, but I can't find any documentation or any reference to the same problem. This question seems like a similar issue but doesn't provide a resolution to my problem.

Here is a code snippet that I'm using to write to the SQLite database:

        var conn = new SQLiteConnection("Data Source=" + connectionString);
        conn.Open();

        var debugEntriesTableQuery = "CREATE TABLE ...";

        var cmd = conn.CreateCommand();

        cmd.CommandText = debugEntriesTableQuery;

        cmd.ExecuteNonQuery();

        conn.Close();

Is there another step needed to properly close the connection to the database and inform the dll and the connection has closed?

I am using this code inside a data solution that I have added to a nuget package and am using in another solution. I am only having this problem when building/cleaning the solution that is using my nuget package.

like image 359
mem27 Avatar asked Nov 27 '14 17:11

mem27


1 Answers

Killing the IIS Express process solves this error for me as pointed out by the link Eric points to. I am using Visual Studio 2015 community. I exit the IIS Express process from the taskbar.

enter image description here

enter image description here

like image 170
AJ Dhaliwal Avatar answered Nov 17 '22 09:11

AJ Dhaliwal