最新的SQLite版本错误



刚刚通过Nuget将我的SQLite dll更新到v10.81.0,我收到了如下错误。这种情况发生在首次成功执行一次或多次之后(不确定)。环境是x64计算机上的vs2010,但内部版本设置针对x86。

我使用SQLite对我的NHibernate映射进行单元测试。在过去,我经常发现SQLite有点"古怪",所以我不愿意使用工作单元测试夹具(见下文)

有人知道这里出了什么问题吗?

干杯,
Berryl

错误消息

Unable to copy file "...x86SQLite.Interop.dll" to "binDebugx86SQLite.Interop.dll". The process cannot access the file 'binDebugx86SQLite.Interop.dll' because it is being used by another process. Parties.Data.Impl.NHib.Tests

单元测试夹具(足以显示文件访问权限)

public abstract class SQLiteTestFixture
{
    protected override void BeforeAllTests()
    {
        _configureDbFile();
        base.BeforeAllTests();
    }
    protected override void AfterAllTests()
    {
        base.AfterAllTests();
        _deleteAllDbFiles();
    }
    #region Db File Maintenance
    /// <summary>
    /// Using a file is likely slower than just memory but not noticeably so far,
    /// AND seems to be a bit more stable
    /// </summary>
    private const string DB_FILE_SUFFIX = ".Test.db";
    /// <summary>
    /// Just make some random file name with a known suffix, so we can clean up when done.
    /// </summary>
    private void _configureDbFile()
    {
        _dbFile = Path.GetFullPath(Guid.NewGuid().ToString("N") + DB_FILE_SUFFIX);
        // highly unlikely but just in case the same file is already out there
        _deleteDbFile();
    }
    private void _deleteDbFile()
    {
        if (File.Exists(_dbFile)) File.Delete(_dbFile);
    }
    private static void _deleteAllDbFiles()
    {
        var files = Directory.GetFiles(Directory.GetCurrentDirectory(), "*" + DB_FILE_SUFFIX);
        foreach (var file in files)
        {
            File.Delete(file);
        }
    }
    private string _dbFile;
    #endregion
}

}

我在VS2010和TestDriven.Net的SQLite 1.0.88.0中遇到了这个问题。我尝试了几个SO问题的答案,但唯一对我有效的是:

  1. 工具->选项->测试驱动的.Net->常规
  2. 运行测试下,取消选中"在测试运行之间缓存测试进程"
  3. 重新启动Visual Studio

您现在应该能够运行测试、调试测试、重建等,而无需重新启动进程或Visual Studio。

KB文章描述了的一个可能原因

  • http://support.microsoft.com/kb/313512/en-us

以下大部分暂时解决了问题

  • 重新启动Visual Studio
  • http://aspadvice.com/blogs/ssmith/archive/2005/03/21/1849.aspx
  • 关闭casini Web服务器

将SQLLite dll的"Copy to Output Directory"更改为"Copy if later"即可。(更改属性后可能需要重新启动VS)

最新更新