Ngugi1 / sqlite-net

Automatically exported from code.google.com/p/sqlite-net
0 stars 0 forks source link

AccessViolationException in ExecuteQuery #3

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The ExecuteQuery<T> ()  occasionally with produce 

Unhandled Exception: System.AccessViolationException in:SQLite3.ColumnName 
(stmt, i), 
If I debug inside the SQLite the error is in 

SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){
  if( p ){
    sqlite3GlobalConfig.mutex.xMutexLeave(p);
  }
}
which is called at the end of  the  *columnName(......) call
=================================================

        public IEnumerable<T> ExecuteQuery<T> () where T : new()
        {
            var stmt = Prepare ();

            var props = Orm.GetColumns (typeof(T));
            var cols = new System.Reflection.PropertyInfo
[SQLite3.ColumnCount (stmt)];
            for (int i = 0; i < cols.Length; i++) {
                cols[i] = MatchColProp 
(SQLite3.ColumnName (stmt, i), props);
            }

            while (SQLite3.Step (stmt) == SQLite3.Result.Row) 
{
                var obj = new T ();
                for (int i = 0; i < cols.Length; i++) {
                    if (cols[i] == null)
                        continue;
                    var val = ReadCol (stmt, i, cols
[i].PropertyType);
                    cols[i].SetValue (obj, val, 
null);
                }
                yield return obj;
            }

            SQLite3.Finalize (stmt);
        }

=======================================
I have tested on Win Vista and Win 7. No multithreading.
Simple Select statement:  Query<EmailAccount>(string.Format("select * from 
EmailAccount where Id = {0}", Id));
Any ideas for the cause will be appreciated. I have been fighting this for 
the last 24 hours.

Original issue reported on code.google.com by ogimit...@gmail.com on 5 Dec 2009 at 8:28

GoogleCodeExporter commented 9 years ago
Sorry for my lack of attention, I will look into this as soon as I can.

Original comment by frank.al...@gmail.com on 23 Jan 2010 at 7:40

GoogleCodeExporter commented 9 years ago

Original comment by frank.al...@gmail.com on 23 Jan 2010 at 7:40

GoogleCodeExporter commented 9 years ago
This was fixed thanks to Geoff Norton.

Original comment by frank.al...@gmail.com on 23 Jan 2010 at 10:44