System.AccessViolationException: Attempted to read or write 返回
Application: supermarket.exe
CoreCLR Version: 7.0.22.51805
.NET Version: 7.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
Stack:
at SQLitePCL.SQLite3Provider_e_sqlcipher+NativeMethods.sqlite3_step(SQLitePCL.sqlite3_stmt)
at SQLitePCL.SQLite3Provider_e_sqlcipher+NativeMethods.sqlite3_step(SQLitePCL.sqlite3_stmt)
at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(System.Data.CommandBehavior)
at Microsoft.Data.Sqlite.SqliteCommand.ExecuteNonQuery()
at SqlSugar.AdoProvider.ExecuteCommand(System.String, SqlSugar.SugarParameter[])
at SqlSugar.UpdateableProvider`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecuteCommand()
at SqlSugar.Storageable`1[[System.__Canon, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ExecuteCommand()
程序运行一段事件 就会这样
热忱回答(3)
-
fate sta VIP0
2022/12/151、SqlSugarClient换成SqlSugarScope (SqlSugarScope 要用单例不然内存会增加)
2、异步 :排查是不是少了await,是否存在非Task返回值方法
3、多租户: db.GetConnection 换成 db.GetConnectionScope
4、无脑解决方案 var newdb=db.CopyNew(); new一个db保证线程安全
0 回复 -
v VIP0
2022/12/15public class BaseDAO
{
static bool isFirstRunDb = false;
public static SqlSugarScope db = new SqlSugarScope(new ConnectionConfig()
{
ConnectionString = new SqliteConnectionStringBuilder()
{
DataSource = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\iyuanbaobao\supermarket\supermarketdb",
Mode = SqliteOpenMode.ReadWriteCreate,
Password = "xxxx",
Cache = SqliteCacheMode.Shared,
}.ToString(),
//+ ";PRAGMA journal_mode=WAL;PRAGMA cache_size=5000;PRAGMA synchronous=normal",
DbType = DbType.Sqlite,//数据库类型
IsAutoCloseConnection = true //不设成true要手动close
}
, configAction(db)
);
BLL:
BaseDAO.db.Insertable(goods).ExecuteCommand();
调用方式
我使用了 最新版本的 就出现这种情况
以前未出现这种情况
0 回复 -
fate sta VIP0
2022/12/15提供完整DEMO吧 暂时看不出原因
0 回复