During debugging another project, the Close of NpgsqlConnection raised a NullReferenceException.
Debugger halted at the line with // *** since Connector variable was null:
else // Non-pooled connection
{
if (EnlistedTransaction == null)
Connector.Close();
// If a non-pooled connection is being closed but is enlisted in an ongoing
// TransactionScope, simply detach the connector from the connection and leave
// it open. It will be closed when the TransactionScope is disposed.
Connector.Connection = null; // *** CONNECTOR == NULL
EnlistedTransaction = null;
}
Suggested change:
else // Non-pooled connection
{
if (Connector != null)
{
if (EnlistedTransaction == null)
Connector.Close();
// If a non-pooled connection is being closed but is enlisted in an ongoing
// TransactionScope, simply detach the connector from the connection and leave
// it open. It will be closed when the TransactionScope is disposed.
Connector.Connection = null; // *** CONNECTOR == NULL
}
EnlistedTransaction = null;
}
Details:
HResult=0x80004003
Message=Object reference not set to an instance of an object.
Source=Npgsql
StackTrace:
at Npgsql.NpgsqlConnection.Close(Boolean wasBroken)
in C:\projects\npgsql\src\Npgsql\NpgsqlConnection.cs:line 644
During debugging another project, the Close of NpgsqlConnection raised a NullReferenceException.
Debugger halted at the line with
// ***since Connector variable was null:Suggested change:
Details: