简体   繁体   English

最新的SQLite版本错误

[英]latest SQLite version errors

Having just updated my SQLite dll via Nuget to v1.0.81.0, I am getting errors like the one below. 刚刚通过Nuget将我的SQLite dll更新为v1.0.81.0,我收到的错误如下所示。 This happens AFTER first executing successfully one or more times (not sure). 首次成功执行一次或多次(不确定)后会发生这种情况。 The environment is vs2010 on an x64 machine but with build setting targeting x86. 环境是x64计算机上的vs2010,但是针对x86的构建设置。

I use SQLite to unit test my NHibernate mappings. 我使用SQLite对我的NHibernate映射进行单元测试。 Having frequently found SQLite a bit "cranky" in the past, I am reluctant to mess with a working unit test fixture (see below) 在过去经常发现SQLite有点“胡思乱想”,我不愿意弄乱工作单元测试夹具(见下文)

Anybody have a clue what is going wrong here? 有人知道这里出了什么问题吗?

Cheers, 干杯,
Berryl Berryl

Error Msg 错误消息

Unable to copy file "...\x86\SQLite.Interop.dll" to "bin\Debug\x86\SQLite.Interop.dll". The process cannot access the file 'bin\Debug\x86\SQLite.Interop.dll' because it is being used by another process. Parties.Data.Impl.NHib.Tests

Unit Test Fixture (enough to show file access anyway) 单元测试夹具(足以显示文件访问权限)

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

}

} }

I was having this problem with SQLite 1.0.88.0 with VS2010 and TestDriven.Net. 我在使用VS2010和TestDriven.Net的SQLite 1.0.88.0时遇到了这个问题。 I tried answers on several SO questions but the only thing that worked for me was this: 我尝试了几个SO问题的答案,但唯一对我有用的是:

  1. Tools -> Options -> TestDriven.Net -> General 工具 - >选项 - > TestDriven.Net - >常规
  2. Under Run Test(s) , Uncheck "Cache tests process between test runs" “运行测试 ”下,取消选中“在测试运行之间缓存测试过程”
  3. Restart Visual Studio 重新启动Visual Studio

You should now be able to run tests, debug tests, rebuild, etc. without having to restart processes or Visual Studio. 您现在应该能够运行测试,调试测试,重建等,而无需重新启动进程或Visual Studio。

KB article describing one possible cause KB文章描述了一个可能的原因

most of the following solve the problem temporarily 以下大部分内容暂时解决了问题

Change the SQLLite dlls "Copy to Output Directory" to "Copy if newer" does the trick. 将SQLLite dll“复制到输出目录”更改为“如果更新则复制”可以解决问题。 (You migth need to restart VS after changing the property) (您需要在更改属性后重新启动VS)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM