Page 1 of 1

QTAgent32 holding file open

Posted: Tue 03 Jan 2012 14:46
by dsdevoy
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();
                }
            }
        }


Posted: Thu 05 Jan 2012 04:05
by dsdevoy
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!)

Posted: Tue 10 Jan 2012 11:20
by StanislavK
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.

Re: QTAgent32 holding file open

Posted: Sun 10 Jun 2012 15:22
by dumian
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

Re: QTAgent32 holding file open

Posted: Thu 14 Jun 2012 12:17
by Pinturiccio
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.