QTAgent32 holding file open

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for SQLite
Post Reply
dsdevoy
Posts: 9
Joined: Thu 29 Dec 2011 17:09

QTAgent32 holding file open

Post by dsdevoy » Tue 03 Jan 2012 14:46

In using VS2010/.Net 4.0 unit testing, a call to CreateDatabase() during a unit test results in QTAgent32.exe (the VS Test Executor) holding the resulting db file open. Explicitly calling the Dispose method on the DataContext at the end of the test does not cause the file handle to be disposed.
The only workaround I have found is to either restart VS altogether or use TaskManager to kill the QTAgent32.exe process, which will restart itself automatically (without the open file handle). Not a very elegant solution, methinks.

Code: Select all

        public DBDataContext CreateContext(string path, bool failIfMissing)
        {
            SQLiteConnectionStringBuilder sb = new SQLiteConnectionStringBuilder();
            sb["Data Source"] = path;
            sb["FailIfMissing"] = failIfMissing;
            string connectionString = sb.ToString();
            DBDataContext db = new DBDataContext(connectionString);
            if (!db.DatabaseExists())
            {
                db.CreateDatabase();
            }
            return (db);
        }

        [TestMethod]
        public void CreateDb()
        {
            DBDataContext db = null;
            string path = @"E:\DBTest\DBTest.db";
            File.Delete(path);
            try
            {
                db = CreateContext(path, /*failIfMissing*/false);
                Assert.IsTrue(db.Draws.Count() == 0);
                Draw newDraw = new Draw();
                .....
                db.Draws.InsertOnSubmit(newDraw);
                db.SubmitChanges();
                Assert.IsTrue(db.Draws.Count() == 1);
            }
            finally
            {
                if (db != null)
                {
                    db.Dispose();
                }
            }
        }


dsdevoy
Posts: 9
Joined: Thu 29 Dec 2011 17:09

Post by dsdevoy » Thu 05 Jan 2012 04:05

Actually, the file handle is dangling whenever a DataContext goes out of scope, whether CreateDatabase() is invoked or not.
Is there some method (other than Dispose()) on the DataContext that I could (or need to) call to cause the DataContext to drop this handle?
Thanks.
(BTW: I am mostly liking this product at lot!)

StanislavK
Devart Team
Posts: 1710
Joined: Thu 03 Dec 2009 10:48

Post by StanislavK » Tue 10 Jan 2012 11:20

Thank you for the report. Apparently, the issue is caused by the connection being kept in the connection pool. To resolve the problem, you can disable the pooling (e.g., set the 'Pooling' connection string parameter to false).

Also, we will add the SQLiteConnection.ClearAllPools method, so that it will be possible to manually release all handles to database files. This functionality will be available in the nearest build.

dumian
Posts: 13
Joined: Sat 09 Jun 2012 19:10
Contact:

Re: QTAgent32 holding file open

Post by dumian » Sun 10 Jun 2012 15:22

Hi dsdevoy,

short question , how you set the licensing of the provider for the server test build, because we have in issue now using embedded compiled licenses file, we got always "License not valid due to the problems with dotConnect for Oracle installation."

thanks

Pinturiccio
Devart Team
Posts: 2420
Joined: Wed 02 Nov 2011 09:44

Re: QTAgent32 holding file open

Post by Pinturiccio » Thu 14 Jun 2012 12:17

The "License not valid due to the problems with dotConnect for Oracle installation." exception occurs when you have some issue during installation. For fixing the license issue perform the following:
1. Uninstall dotConnect for Oracle;
2. Remove all Devart.* and policy.*.Devart.* files from the GAC;
3. Clear the Program Files\Devart\dotConnect and Program Files\Common Files\Devart\dotConnect folders;
4. Install dotConnect for Oracle;
5. Rebuild the license resource on the development workstation and add it to the project on Team Build;
6. Delete all files from the bin and obj folders and rebuild the project.

If this does not help, please send us the QTAgent32.exe file with our built-in license, we will check whether the resource is valid.

Post Reply