-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Closed as duplicate of#18307
Closed as duplicate of#18307
Copy link
Labels
Description
When I call Dispose
on an SqliteDataReader
after I called a Close
, an InvalidOperationException
gets thrown and caught by Dispose(bool)
. This doesn't cause a malfunctioning program, but it causes a severe slow-down due to exceptions being slow.
To Reproduce
In Visual Studio, enable stopping the program execution when an InvalidOperationException
gets thrown.
Start the following program:
using System;
using Microsoft.Data.Sqlite;
namespace TestSqliteInvOpEx
{
class Program
{
static void Main(string[] args)
{
using (var conn = new SqliteConnection("Data Source=:memory:"))
{
conn.Open();
using (var createTableCmd = conn.CreateCommand())
{
createTableCmd.CommandText = "create table test (a int)";
createTableCmd.ExecuteNonQuery();
}
using (var insertCmd = conn.CreateCommand())
{
insertCmd.CommandText = "insert into test (a) values (1)";
insertCmd.ExecuteNonQuery();
}
using (var queryCmd = conn.CreateCommand())
{
queryCmd.CommandText = "select * from test";
using (var reader = queryCmd.ExecuteReader())
{
while (reader.Read())
{
Console.WriteLine(reader.GetValue(0));
}
reader.Close();
}
}
conn.Close();
}
}
}
}
Stack trace:
Microsoft.Data.Sqlite.dll!Microsoft.Data.Sqlite.SqliteDataReader.NextResult() Unbekannt
Microsoft.Data.Sqlite.dll!Microsoft.Data.Sqlite.SqliteDataReader.Dispose(bool disposing) Unbekannt
System.Data.Common.dll!System.Data.Common.DbDataReader.Dispose() Unbekannt
> TestSqliteInvOpEx.dll!TestSqliteInvOpEx.Program.Main(string[] args) Zeile 38 C#
Additional context
Microsoft.Data.Sqlite version: 3.0.0
Target framework: .NET Core 3.0
Operating system: Windows 10 Pro 1903