[GIS] Spatialite in .NET Application – AccessViolationException was unhandled

cspatialite

I am trying to use Spatialite in a .NET application using the System.Data.SQLite provider. Interestingly enough, everything works as expected except an error gets thrown at the very end when the connection is closed. The specific error is "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." The same thing happens if I wrap this function is a using statement. If I remove the conn.Close() it still bombs out.

Any ideas?

try
            {
                conn = new SQLiteConnection(connectionString);
                conn.Open();
                cmd = conn.CreateCommand();

                cmd.CommandText = @"SELECT load_extension('libspatialite-2.dll');";
                cmd.ExecuteScalar();

                cmd.CommandText = "SELECT AsBinary(Geometry) AS WKB from country";
                rdr = cmd.ExecuteReader();

                while (rdr.Read())
                {
                    //do work
                }

            }
            catch
            {
                // error handling here
            }
            finally
            {
                if (!rdr.IsClosed)
                    rdr.Close();

                rdr = null;
                cmd = null;
                conn.Close();
                conn = null;
            }

Best Answer

ask your question on http://groups.google.com/group/spatialite-users/topics?pli=1

There are many references on the use of .NET

Related Question