gpt4 book ai didi

c# - C#数据库应用程序在清理表时不断崩溃(?)

转载 作者:行者123 更新时间:2023-12-03 16:38:50 24 4
gpt4 key购买 nike

我已经将服务/应用程序连接到mssql服务器,并且有时使用以下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)

好吧,事实上,我不使用计时器,(并且我不确定计时器在哪里确切地启动了),而且我找不到导致崩溃的原因。
您是否有经验/您是否已经明白为什么会这样,以及如何避免(或忽略它)?服务的运行时间对我来说至关重要。

最佳答案

您是否正确清理数据库连接,即使用usingtry..finally

在应用程序运行时,使用perfmon.exe查看性能计数器类别“用于Sql Server的.Net数据提供程序”中的计数器,并检查正在使用的连接和池的数量。如果这种情况持续增长,则表明您正在泄漏连接,这可能会导致此错误。

关于c# - C#数据库应用程序在清理表时不断崩溃(?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1158473/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com