I have a page that checks that a user is in a particular role before performing some task, and have had no problem with functionality and have made no obvious related changes to the code in question. The site is on my development machine (Windows Vista) running IIS 7.0 and the database is MS SQL 2005 on a separate server. Suddenly, all calls to the User.IsInRole
are resulting in
System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count.
I'm sure restarting IIS will "resolve" the issue, but I'd like to understand what caused it so I can ensure it doesn't happen on my production site.
The top of the stack trace is:
[SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count.] System.Threading.Semaphore.Release(Int32 releaseCount) +6065293 System.Data.ProviderBase.DbConnectionPool.PutNewObject(DbConnectionInternal obj) +57 System.Data.ProviderBase.DbConnectionPool.DeactivateObject(DbConnectionInternal obj) +338 System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal obj, Object owningObject) +163 System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory) +117 System.Data.SqlClient.SqlInternalConnection.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory) +37 System.Data.SqlClient.SqlConnection.Close() +158 System.Web.DataAccess.SqlConnectionHolder.Close() +25 System.Web.Security.SqlRoleProvider.GetRolesForUser(String username) +847 System.Web.Security.RolePrincipal.IsInRole(String role) +182
This issue was fixed by restarting ASP.NET Development Server on windows taskbar.
Or permanently by adding 'Pooling=False;' to the connection string should solve the issue.