微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

当通过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;”到连接字符串应该解决问题。

原文地址:https://www.jb51.cc/aspnet/254615.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐