admin管理员组文章数量:1391981
I am working on a MAUI application which uses sqlite-net-pcl as its ORM. When I try to delete the DB file from the app (System.IO.File.Delete(dbFilePath)) I get the following exception on Windows: The process cannot access the file 'dbFilePath' because it is being used by another process.
The API of this ORM doesn't seem to offer any commands to forcefully close any connections to the DB file.
I've tried using:
GC.Collect();
GC.WaitForPendingFinalizers(); no luck here.
The async connections used in the app, I do the following:
try
{
dbConnection = new SQLiteAsyncConnection(DBConnectionString);
await dbConnection.<do whatever in the DB>;
}
catch (Exception ex)
{
ParentPage?.DisplayAlert("Error", $"{ex.Message}", "Close");
return false;
}
finally
{
await dbConnection.CloseAsync();
}
For the synchronous connections I don't have full control over since that's being managed by another department and they provide me with a nuget package so, maybe the problem is there but I cannot do much about it.
I know for a fact the file is locked by my own app, I used 3rd party tools to identify which process is locking the file and it's my app.
Any ideas on how to force a file lock release here?
本文标签: windowsHow can I force my own app to release a lock over its SQLite DB fileStack Overflow
版权声明:本文标题:windows - How can I force my own app to release a lock over its SQLite DB file? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744688205a2619832.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论