当通过ASP.NET成员资格检查用户角色时,SemaphoreFullException

我有一个页面,在执行一些任务之前检查用户是否处于特定的角色,并且对功能没有问题,并且没有对相关代码进行明显的相关更改。该站点在我的开发计算机(Windows Vista)上运行IIS 7.0,数据库是MS sql 2005在单独的服务器上。突然,对User.IsInRole的所有调用都会导致

System.Threading.SemaphoreFullException: Adding the specified count to the semaphore would cause it to exceed its maximum count.

我确定重新启动IIS将“解决”的问题,但我想了解是什么原因,所以我可以确保它不会发生在我的生产网站。

堆栈跟踪的顶部是:

[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

解决方法

此问题已通过在Windows任务栏上重新启动ASP.NET开发服务器修复。

或永久添加“Pooling = False;”到连接字符串应该解决问题。

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....