views:

94

answers:

2

Hello, I've got service/application connected to mssql server, and it sometimes crashes terribly with following stacktrace:

Uncaught exception: ArgumentOutOfRangeException - Specified argument was out of the range of valid values.
Parameter name: capacity, thrown at: mscorlib
Stack Trace:
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument)
   at System.Collections.Generic.Dictionary`2..ctor(Int32 capacity, IEqualityComparer`1 comparer)
   at System.Data.ProviderBase.DbConnectionFactory.PruneConnectionPoolGroups(Object state)
   at System.Threading._TimerCallback.TimerCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading._TimerCallback.PerformTimerCallback(Object state)

Well, in fact, i don't use timer, (and i am not sure WHERE exactly the timer is being started), and I cant find the reason for this crash. Do you have any experience/do you have seen why exactly this happens, and how to avoid it (or ignore it?). The service's running time is crucial for me.

+3  A: 

Are you cleaning up your database connections correctly, i.e. using using or try..finally?

Have a look at the counters in performance counter category '.Net Data Provider for Sql Server' with perfmon.exe while your app is running, and check the number of connections and pools you are using. If this keeps growing it is a good sign you are leaking connections which might lead to this error.

Matt Howells
No, I'm not, I'm connected for the whole service's while time.
Yossarian
You are probably using connection pooling, in which case you should open the connection, do your work, then close it when you are done.
Matt Howells
A: 

that timer is probably an internal part of the connection management.

ar eyou sure that you dont actually ahve a parameter called capacity on one of the sp's?

If so are you sure that it is never overflowing?

John Nicholas