This project is read-only.

Got intermittent error: Invalid operation. The connection is closed.


Hi, our application is getting this error sometimes:
Invalid operation. The connection is closed.
at System.Data.SqlClient.SqlConnection.GetOpenConnection()
at System.Data.SqlClient.SqlConnection.get_Parser()
at System.Data.SqlClient.SqlConnection.Open()
at NetSqlAzMan.SqlAzManStorage.OpenConnection()

After reviewing the source code (downloaded from CodePlex), I think there might be an issue in source code here:

private ConnectionState backupConnectionState = ConnectionState.Closed;

public void OpenConnection()
        this.backupConnectionState = this.db.Connection.State;
        if (this.backupConnectionState == ConnectionState.Closed)

    public void CloseConnection()
        if (this.db.Connection.State == ConnectionState.Open && this.backupConnectionState == ConnectionState.Closed)
So, look like SqlAzManStorage is always keeping connection open for usage. From the article that I read,

We strongly recommend that you always close the connection when you are finished using it so that the connection will be returned to the pool.

Can you help? Thanks.