Alex Rivera | Logout

SQLite.Interop.dll locked after running Visual Studio 2012 Unit Test Framework tests

Asked 2012-10-16T16:38:44.243
20
  • Visual Studio 2012
  • SQLite 1.0.82.0 (from nuget)

I am trying to use the "Run All" command in the "Test Explorer" The following error happens after you run the test once ... after that it will not build anymore, until you restart visual studio

Here is the build error

The Process cannot access the file 'SQLite.Interop.dll' because it is being used by another process

here is the code

using System.Data.SQLite;
using Microsoft.VisualStudio.TestTools.UnitTesting;

namespace Test.Sqlite
{
    [TestClass]
    public class Test_Sqlite_Locking
    {
        [TestMethod]
        public void can_create_table()
        {
            using(var fact = new SQLiteFactory())            
            using (var conn = fact.CreateConnection())
            {
                conn.ConnectionString = "Data Source=:memory:;Version=3;New=True;";
                conn.Open();
                //conn.Close();                
            }

            //SQLiteConnection.ClearAllPools();
            //GC.Collect();
        }
    }
}

I have tried, closing connection, calling ClearAllPools, GC.Collect, and creating the SQLiteConnection directly (instead of the Factory) ... still same issue

This DOES work if you DEBUG ALL TESTS ... but it is when you just Run the tests that this seems to lock it up

Edit
Report

1 Answer

8

Try this:

  • In VS.NET, click on Tools \ Options
  • When the dialog appears, click on "Test Tools"
  • Click on "Test Execution"
  • Uncheck the box "Keep test execution engine running between tests"
  • Click OK and restart VS.NET

You should be able run SQLite based tests now without having to restart.

answered 2012-11-17T03:02:41.333

Your Answer