After Update from 3.0.4 to 3.0.13 | ExecuteReader requires an open and available Connection. The connection's current state is Connecting
oiBio opened this issue · comments
Hello,
after updating to the latest version of westwind utilities i get an InvalidOperationException while initiating a AppConfiguration with an SqlServerConfigurationProvider.
This is my Default-Provider
protected override IConfigurationProvider OnCreateDefaultProvider(string sectionName,
object configData)
{
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString;
string tableName = "ApplicationConfiguration";
var providerSql = new SqlServerConfigurationProvider<ApplicationConfiguration>()
{
ConnectionString = connectionString,
Tablename = tableName,
Key = 1,
};
return providerSql;
}
With the old version everything works as expected
i initiate the the ApplicationConfiguration within the contructor of a static class. And i am calling it in the Application_Start() of my MVC-Application.
I can't duplicate this. It works for me both in .NET Standard and Net45 modes for the tests configured for it.
The error seems to suggest that there's a problem with the connection - perhaps being slow to respond data connection?
Internally the SqlDataAccessProvider creates creates a command which in turn calls Open Connection:
if (_Connection.State != ConnectionState.Open)
_Connection.Open();
I'm guessing there's something else happening in your application perhaps that's using the same SQL connection asynchronously and it's in a mixed state of some sort? I dunno. Maybe this will help https://stackoverflow.com/a/9707060/11197.