0

私の c# アプリケーションでは、次のような例外に直面しています。Get item failed, reason:Attempted to read or write protected memory. これは多くの場合、他のメモリが破損していることを示しています。

上記の例外は、2 つの URL が同時に呼び出された場合に発生します。以下に説明されている、

http://localhost.:8081/statistics/postdata?sessionId=utviuataoe http://localhost.:8081/item/detail/2916/content

postdata は、毎回バックグラウンド プロセスである sqlite データベースにデータを書き込みます。同時に、いくつかの画像をエンド ユーザーに表示する必要があると、例外が発生します。

使用するデータベースは sqlite です。sqlite にデータを書き込むには、以下のコードが使用されます。

if (conn.State != ConnectionState.Open)
                Open(DataFile);

            using (SQLiteTransaction dbtrans = conn.BeginTransaction())
            {

                using (cmd.Connection = conn)
                {


                    try
                    {
                        cmd.CommandText = cmd.CommandText;
                        cmd.Transaction = dbtrans;
                        ireturn = cmd.ExecuteNonQuery();
                        dbtrans.Commit();
                        cmd.Dispose();
                        conn.Close();
                    }
                    catch (Exception)
                    {
                    }
                }
            }

以下のコードを使用してデータを読み取るには、

 public SQLiteDataReader ExecuteSQL(String sqlExpr)
        {


            if (conn.State != ConnectionState.Open)
                Open(DataFile);

            using (SQLiteCommand cmd = conn.CreateCommand())
            {

                cmd.CommandText = sqlExpr + ";PRAGMA read_uncommitted = 1;";
                cmd.CommandType = CommandType.Text;
                return cmd.ExecuteReader();
            }


        }

よろしくサンギータ

4

0 に答える 0