刚刚通过 Nuget 将我的 SQLite dll 更新到 v1.0.81.0,我收到如下错误。这发生在第一次成功执行一次或多次之后(不确定)。环境是 x64 机器上的 vs2010,但构建设置针对 x86。
我使用 SQLite 对我的 NHibernate 映射进行单元测试。过去经常发现 SQLite 有点“古怪”,我不愿意弄乱工作单元测试夹具(见下文)
有人知道这里出了什么问题吗?
干杯,
贝里尔
错误信息
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
单元测试夹具(无论如何都足以显示文件访问)
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
}
}