繁体   English   中英

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

[英]Arithmetic overflow exception when opening SQL connection

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

最令人惊讶的是,该应用程序运行正常,并且可以与服务器正确通信,执行许多不同的查询,但是突然出现此异常。 我注意到此异常在某些Windows更新后开始出现(不知道是哪个)。

我已经研究了.NET代码,但不知道是什么原因导致那里的算术溢出异常...

- 堆栈跟踪 -

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()

我有同样的问题。 Lavasoft也是一个原因。 我在“程序和功能”中检查是否有任何Lavasoft程序,但我惊讶地发现名为Lavasoft的WebCompanion应用程序。 我还发现了一个正在运行的服务LavasoftTcpService。

  1. 我停止了服务LavasoftTcpService(来自services.msc)
  2. 我从“程序和功能”中卸载了WebCompanion。
  3. 上面提到的两个dll(C:\\ Windows \\ System32和C:\\ Windows \\ SysWOW64中的LavasoftTcpService.dll和LavasoftTcpService64.dll)仍然存在。 我改了名字,一个问题消失了。

在执行这些步骤之前,我尝试仅更改dlls的名称,并且存在一个解析本地主机的问题:系统正在寻找0.0.0.0,而不是127.0.0.1。 Ping给我一个错误消息“ Ping请求找不到主机localhost。请检查名称,然后重试”

3个步骤解决了问题。

我们遇到了同样的问题,这是由LavasoftTcpService64.dll引起的。 摆脱这个不那么容易的方法 ,解决了这个问题。 检查以下文件夹是否存在: C:\\WindowsC:\\Windows\\System32C:\\Windows\\SysWOW64

感谢Nguyen Quy Hy找出根本原因。

我确认罪魁祸首是Lavasoft Ad-Aware或WebCompanion。 调用SqlConnection.Open()时,将引发System.OverflowException。 仅适用于LocalDB。

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

厄休拉说的就是解决方案。

我遇到了同样的问题,该问题阻止安装Azure Storage Emulator,即AzureStorageEmulator.exe开始产生了类似的堆栈跟踪和异常。 我可以启动仿真器,但无法启动它。 删除Lavasoft dll并重置winsock堆栈可以解决问题。 因此为我工作,并同样感谢Nguyen Quy Hy和这篇文章。

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

  1. 从服务停止LavasoftTcpService64服务,并
  2. 从程序和功能中卸载Web-companion,它开始工作,以防万一问题仍然存在,请重新启动计算机,希望它能对您有所帮助。

我本人只是遇到此错误, 这里的第二个选项对我有所帮助。

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

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

  3. 重新启动计算机。

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM