This question is locked. New answers and comments are not allowed.
Since upgrading a solution to use Visual Studio 2013 yesterday I'm getting the following error when trying to access the Connection property of a DataContext object not long after launching the application - the application may load the first page (sometimes the exception is thrown before a page loads) but then shortly this exception is thrown.
The application is still targeting the .NET 4.0 framework and the application works perfectly in VS 2010. Is there something I need to do in order to get the application to work with IIS Express in VS 2013?
"An exception of type 'Telerik.OpenAccess.OpenAccessException' occurred in Telerik.OpenAccess.dll but was not handled in user code
Additional information: System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.connect(ConnectionString connectionString, PropertySet driverProps, ConnectionPoolType poolType, LogEventStore pes)
at OpenAccessRuntime.Relational.conn.RelationalConnectionPool.createRealCon()
at OpenAccessRuntime.Relational.conn.RelationalConnectionPool.CreatePlainAdoConnection()
at OpenAccessRuntime.Relational.conn.RelationalConnectionPool.getConnection(Boolean highPriority, Boolean autoCommit, Int32 smId)
at OpenAccessRuntime.Relational.RelationalStorageManager.obtainConnection(Boolean forWriting)"
The following method is where the exception is being thrown. I am manipulating the connection string because there is a requirement to be able to change the store name dynamically and on the fly:
public static string GetConnectionString<DC>(bool extendedTimeout, bool storeOverride, string storeName)
where DC : OpenAccessContext
{
string connectionString = string.Empty;
int timeoutTarget = DataSettings.ConnectionTimeoutDefault;
if (extendedTimeout)
{
timeoutTarget = DataSettings.ConnectionTimeoutExtended;
}
OpenAccessContext dataContext = Activator.CreateInstance<DC>();
bool correctTimeout = true;
if (dataContext != null)
{
if (dataContext.Connection.ConnectionTimeout != timeoutTarget) // this is where the exception is thrown
{
correctTimeout = false;
}
}
else
{
correctTimeout = false;
}
if (dataContext != null)
{
string currentConnectionString = dataContext.Connection.ConnectionString;
if (!string.IsNullOrWhiteSpace(currentConnectionString))
{
SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder(currentConnectionString);
if (correctTimeout == false)
{
connectionStringBuilder.ConnectTimeout = timeoutTarget;
}
if (storeOverride == true)
{
if (!string.IsNullOrWhiteSpace(storeName))
{
connectionStringBuilder.InitialCatalog = storeName;
}
else
{
connectionStringBuilder.InitialCatalog = "InvalidStoreName";
}
}
connectionStringBuilder.MultipleActiveResultSets = false;
connectionStringBuilder.ContextConnection = false;
try
{
connectionString = connectionStringBuilder.ConnectionString;
}
catch (Exception ex)
{
connectionString = ex.Message;
// TODO: Log exception...
}
}
}
return connectionString;
}
The application is still targeting the .NET 4.0 framework and the application works perfectly in VS 2010. Is there something I need to do in order to get the application to work with IIS Express in VS 2013?
"An exception of type 'Telerik.OpenAccess.OpenAccessException' occurred in Telerik.OpenAccess.dll but was not handled in user code
Additional information: System.InvalidOperationException: Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
at Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver.connect(ConnectionString connectionString, PropertySet driverProps, ConnectionPoolType poolType, LogEventStore pes)
at OpenAccessRuntime.Relational.conn.RelationalConnectionPool.createRealCon()
at OpenAccessRuntime.Relational.conn.RelationalConnectionPool.CreatePlainAdoConnection()
at OpenAccessRuntime.Relational.conn.RelationalConnectionPool.getConnection(Boolean highPriority, Boolean autoCommit, Int32 smId)
at OpenAccessRuntime.Relational.RelationalStorageManager.obtainConnection(Boolean forWriting)"
The following method is where the exception is being thrown. I am manipulating the connection string because there is a requirement to be able to change the store name dynamically and on the fly:
public static string GetConnectionString<DC>(bool extendedTimeout, bool storeOverride, string storeName)
where DC : OpenAccessContext
{
string connectionString = string.Empty;
int timeoutTarget = DataSettings.ConnectionTimeoutDefault;
if (extendedTimeout)
{
timeoutTarget = DataSettings.ConnectionTimeoutExtended;
}
OpenAccessContext dataContext = Activator.CreateInstance<DC>();
bool correctTimeout = true;
if (dataContext != null)
{
if (dataContext.Connection.ConnectionTimeout != timeoutTarget) // this is where the exception is thrown
{
correctTimeout = false;
}
}
else
{
correctTimeout = false;
}
if (dataContext != null)
{
string currentConnectionString = dataContext.Connection.ConnectionString;
if (!string.IsNullOrWhiteSpace(currentConnectionString))
{
SqlConnectionStringBuilder connectionStringBuilder = new SqlConnectionStringBuilder(currentConnectionString);
if (correctTimeout == false)
{
connectionStringBuilder.ConnectTimeout = timeoutTarget;
}
if (storeOverride == true)
{
if (!string.IsNullOrWhiteSpace(storeName))
{
connectionStringBuilder.InitialCatalog = storeName;
}
else
{
connectionStringBuilder.InitialCatalog = "InvalidStoreName";
}
}
connectionStringBuilder.MultipleActiveResultSets = false;
connectionStringBuilder.ContextConnection = false;
try
{
connectionString = connectionStringBuilder.ConnectionString;
}
catch (Exception ex)
{
connectionString = ex.Message;
// TODO: Log exception...
}
}
}
return connectionString;
}