打开SQL连接时算术溢出异常

本文关键字:溢出 异常 SQL 连接 打开 | 更新日期: 2023-09-27 18:13:03

当打开到底层SQL数据库的SQL连接时,我得到了非常奇怪的ArithmeticOverflowException(下面包括堆栈跟踪)。使用哪个版本的服务器没有区别(我已经验证了MS SQL 2005/2008/2012/2014),错误仍然是一样的。所有最新的更新和补丁从Windows更新安装。操作系统是Windows 8.1/10(在两个系统上发生相同)。服务器在本地安装,并通过用户和密码进行连接。连接超时验证范围从15到1000秒。

最令人惊讶的事情是应用程序工作正常,并与服务器正常通信,执行许多不同的查询,但突然这个异常发生了。我注意到这个异常在一些windows更新后开始出现(不知道是哪一个)。

我已经研究了。net代码,但是不知道是什么导致了算术溢出异常…

——STACK TRACE——

in SNIOpenSyncExWrapper(SNI_CLIENT_CONSUMER_INFO* , SNI_ConnWrapper** )
in SNINativeMethodWrapper.SNIOpenSyncEx(ConsumerInfo consumerInfo, String constring, IntPtr& pConn, Byte[] spnBuffer, Byte[] instanceName, Boolean fOverrideCache, Boolean fSync, Int32 timeout, Boolean fParallel)
in System.Data.SqlClient.SNIHandle..ctor(ConsumerInfo myInfo, String serverName, Byte[] spnBuffer, Boolean ignoreSniOpenTimeout, Int32 timeout, Byte[]& instanceName, Boolean flushCache, Boolean fSync, Boolean fParallel)
in System.Data.SqlClient.TdsParserStateObject.CreatePhysicalSNIHandle(String serverName, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Byte[]& instanceName, Byte[] spnBuffer, Boolean flushCache, Boolean async, Boolean fParallel)
in System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
in System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, Boolean withFailover)
in System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
in System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
in System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
in System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
in System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
in System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
in System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
in System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
in System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
in System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
in System.Data.SqlClient.SqlConnection.Open()

打开SQL连接时算术溢出异常

我也遇到了同样的问题。Lavasoft也是一个原因。我在"程序和功能"中查看了是否有Lavasoft软件,我惊讶地发现了一个名为"Lavasoft的WebCompanion"的应用程序。我还发现了一个正在运行的服务LavasoftTcpService。

  1. 我停止了LavasoftTcpService服务(from services.msc)
  2. 我从程序和功能中卸载了WebCompanion。
  3. 上面提到的两个dll (C:'Windows' system32和C:'Windows'SysWOW64中的LavasoftTcpService.dll和LavasoftTcpService64.dll)仍然在那里。我改了他们的名字,问题就解决了。

在这些步骤之前,我试图只更改dll名称,并且有一个问题要解决localhost:而不是127.0.0.1系统正在寻找0.0.0.0。Ping给我一个错误消息"Ping请求无法找到主机localhost。"请检查名称后再试"

3步解决问题

我们有同样的问题,它是由LavasoftTcpService64.dll引起的。摆脱这个并不容易,但解决了这个问题。检查以下文件夹是否存在:C:'Windows, C:'Windows'System32C:'Windows'SysWOW64

功劳归Nguyen Quy Hy,因为他找到了根本原因。

我确认罪魁祸首是Lavasoft Ad-Aware或WebCompanion。这个系统。调用SqlConnection.Open()时抛出OverflowException。

有趣的是,如果你的应用程序是单实例应用程序,崩溃总是发生,否则它会随机发生。

解决办法就是厄休拉说的。

我有同样的问题,它阻止了Azure存储模拟器的安装,即AzureStorageEmulator.exe start产生了类似的堆栈跟踪和异常。我可以初始化模拟器,但不能启动它。删除Lavasoft dll并重置winsock堆栈就成功了。这是我的工作,同样感谢Nguyen Quy Hy和这篇文章。

我在通过entityframework创建用户时遇到了同样的问题,我通过执行以下步骤找到了解决方案并修复了问题

  1. 从services中停止LavasoftTcpService64服务和
  2. 从程序和功能中卸载web伴侣,它开始工作如果问题仍然存在,重新启动你的机器,希望它会有所帮助。

我自己也遇到了这个错误,这里的选项#2帮助了我。

  1. 请以管理员身份启动命令提示符,右键单击命令提示符并选择以管理员身份运行。

  2. 输入以下命令重置网络适配器(以Enter键结束):

  3. 重启电脑

  4. 请删除这两个文件:
    C:'WINDOWS'system32' LavasoftTcpService64.dllC:'WINDOWS'SysWOW64'LavasoftTcpService.dll(仅适用于64位Windows)

我重命名了文件而不是删除。