Friday, August 23, 2013

Adding the specified count to the semaphore would cause it to exceed its maximum count

I got this unusual exception while working on an ASP.NET project:
"Adding the specified count to the semaphore would cause it to exceed its maximum count error".

I thought it is something related to SQL Server Database Connection String.
After using Query Profiler I was able to run SQL queries directly without any problems.
So this means that the issue in ASP.NET Application not with the SQL Server Database.
I did a research about this issue to figure out a solution and I discovered that this issue related to ADO.NET Connection Pool manager.

The Connection Pool Manager is enabled by default in the connection string.
It will attempt to find a free connection, but if it didn't find a free connection it would threw the exception we are talking about.

To fix this issue all you have to do is to disable the Connection Pool Manager as shown below:


<add name="contest"
connectionString="Data Source=Server1Test;Initial Catalog=DBTest;User ID=UserTest;
Password=PasswordTest;Pooling=False;"
providerName="System.Data.SqlClient" />

Hire Me

Follow me on Facebook

Follow me

Do you find this Blog helpful?

Follow by Email

About Me

My Photo
Expert Senior Software Developer

Microsoft Business Card