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

时间:2022-08-03 01:51:15

I got very weird ArithmeticOverflowException when opening an SQL connection to the underlying SQL database (stack trace included below). It doesn't make a difference which version of the server is used (I've verified MS SQL 2005/2008/2012/2014), error is still the same. All the newest updates and patches from Windows Update installed. OS is Windows 8.1 / 10 (same occurs on both systems). Server is installed locally and the connection is made via user and password. Connection timeout verified in range from 15 to 1000 sec.

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

The most surprising thing is the application works just fine, and communicates with the server properly, executing many various queries, but suddenly this exception occurs. I noticed this exception started showing up after some windows update (no idea which one).

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

I've looked into the .NET code, but have no idea what can cause the arithmetic overflow exception there...

我查看了.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()

6 个解决方案

#1


20  

I had the same problem. Lavasoft was also a reason. I checked in Program and Features if there is any Lavasoft program, and I was surprised to find application called WebCompanion of Lavasoft. I also found a running service LavasoftTcpService.

我有同样的问题。 Lavasoft也是一个原因。如果有任何Lavasoft程序,我检查了程序和功能,我很惊讶地找到了名为Lavasoft的WebCompanion的应用程序。我还找到了一个正在运行的服务LavasoftTcpService。

  1. I stopped the service LavasoftTcpService (from services.msc)
  2. 我停止了服务LavasoftTcpService(来自services.msc)
  3. I uninstalled WebCompanion from Program and Features.
  4. 我从程序和功能中卸载了WebCompanion。
  5. Two above mentioned dlls (LavasoftTcpService.dll and LavasoftTcpService64.dll in C:\Windows\System32 and C:\Windows\SysWOW64) were still there. I changed their name, and a problem dissapeared.
  6. 上面提到的两个dll(LavasoftTcpService.dll和LavasoftTcpService64.dll在C:\ Windows \ System32和C:\ Windows \ SysWOW64中)仍然存在。我改名了,问题消失了。

Before those steps I tried to only change dlls names and there was a problem to resolve localhost: instead of 127.0.0.1 system was looking for 0.0.0.0. Ping was giving me an error message "Ping request could not find host localhost. Please check the name and try again"

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

3 steps resolved the problem.

3个步骤解决了这个问题。

#2


10  

We had the same problem and it was caused by LavasoftTcpService64.dll. Getting rid of this, which is not that easy, fixed the problem. Check the following folders for its presence: C:\Windows, C:\Windows\System32 and C:\Windows\SysWOW64.

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

Credit goes to Nguyen Quy Hy for finding the root cause.

归功于Nguyen Quy Hy寻找根本原因。

#3


3  

I confirm the culprit is Lavasoft Ad-Aware or WebCompanion. The System.OverflowException is thrown when calling SqlConnection.Open(). Only with LocalDB.

我确认罪魁祸首是Lavasoft Ad-Aware或WebCompanion。调用SqlConnection.Open()时抛出System.OverflowException。仅限LocalDB。

Interestingly, the crash occurs always if your app is a single instance application, otherwise it occurs randomly.

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

The solution is what Ursula said.

解决方案就是厄秀拉所说的。

#4


2  

I had the same problem which prevented installation of Azure Storage Emulator i.e. AzureStorageEmulator.exe start produced a similar stack trace and exception. I could init the emulator but not start it. Removal of the Lavasoft dll and resetting the winsock stack did the trick. So worked for me and likewise credit to Nguyen Quy Hy and this post.

我遇到了阻止安装Azure存储模拟器的相同问题,即AzureStorageEmulator.exe启动时产生了类似的堆栈跟踪和异常。我可以初始化模拟器但不能启动它。删除Lavasoft DLL并重置winsock堆栈就可以了。所以对我有用,同样归功于Nguyen Quy Hy和这篇文章。

#5


2  

i had the same problem while creating user through entityframework and i found the solution and fix the problem by doing following steps

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

  1. Stop LavasoftTcpService64 service from services and
  2. 从服务和服务中停止LavasoftTcpService64服务
  3. Uninstall the web-companion from program and features and it started working in case if the problem still exist restart your machine hope it will help.
  4. 从程序和功能中卸载Web伴侣,如果问题仍然存在,它开始工作重新启动您的机器希望它会有所帮助。

#6


1  

I Just encountered this error myself and option #2 from here helped me.

我自己刚刚遇到这个错误,从这里选择#2帮助了我。

  1. Please, start Command Prompt as an administrator by right-clicking it and select Run as administrator.

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

  2. Enter this command to reset the network adapter (end with the Enter key):
    netsh winsock reset

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

  3. Restart the computer.

    重启电脑。

  4. Please, delete these two files:
    C:\WINDOWS\system32\LavasoftTcpService64.dll C:\WINDOWS\SysWOW64\LavasoftTcpService.dll (only for 64-bit Windows)

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

I renamed the files instead of deleting.

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

#1


20  

I had the same problem. Lavasoft was also a reason. I checked in Program and Features if there is any Lavasoft program, and I was surprised to find application called WebCompanion of Lavasoft. I also found a running service LavasoftTcpService.

我有同样的问题。 Lavasoft也是一个原因。如果有任何Lavasoft程序,我检查了程序和功能,我很惊讶地找到了名为Lavasoft的WebCompanion的应用程序。我还找到了一个正在运行的服务LavasoftTcpService。

  1. I stopped the service LavasoftTcpService (from services.msc)
  2. 我停止了服务LavasoftTcpService(来自services.msc)
  3. I uninstalled WebCompanion from Program and Features.
  4. 我从程序和功能中卸载了WebCompanion。
  5. Two above mentioned dlls (LavasoftTcpService.dll and LavasoftTcpService64.dll in C:\Windows\System32 and C:\Windows\SysWOW64) were still there. I changed their name, and a problem dissapeared.
  6. 上面提到的两个dll(LavasoftTcpService.dll和LavasoftTcpService64.dll在C:\ Windows \ System32和C:\ Windows \ SysWOW64中)仍然存在。我改名了,问题消失了。

Before those steps I tried to only change dlls names and there was a problem to resolve localhost: instead of 127.0.0.1 system was looking for 0.0.0.0. Ping was giving me an error message "Ping request could not find host localhost. Please check the name and try again"

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

3 steps resolved the problem.

3个步骤解决了这个问题。

#2


10  

We had the same problem and it was caused by LavasoftTcpService64.dll. Getting rid of this, which is not that easy, fixed the problem. Check the following folders for its presence: C:\Windows, C:\Windows\System32 and C:\Windows\SysWOW64.

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

Credit goes to Nguyen Quy Hy for finding the root cause.

归功于Nguyen Quy Hy寻找根本原因。

#3


3  

I confirm the culprit is Lavasoft Ad-Aware or WebCompanion. The System.OverflowException is thrown when calling SqlConnection.Open(). Only with LocalDB.

我确认罪魁祸首是Lavasoft Ad-Aware或WebCompanion。调用SqlConnection.Open()时抛出System.OverflowException。仅限LocalDB。

Interestingly, the crash occurs always if your app is a single instance application, otherwise it occurs randomly.

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

The solution is what Ursula said.

解决方案就是厄秀拉所说的。

#4


2  

I had the same problem which prevented installation of Azure Storage Emulator i.e. AzureStorageEmulator.exe start produced a similar stack trace and exception. I could init the emulator but not start it. Removal of the Lavasoft dll and resetting the winsock stack did the trick. So worked for me and likewise credit to Nguyen Quy Hy and this post.

我遇到了阻止安装Azure存储模拟器的相同问题,即AzureStorageEmulator.exe启动时产生了类似的堆栈跟踪和异常。我可以初始化模拟器但不能启动它。删除Lavasoft DLL并重置winsock堆栈就可以了。所以对我有用,同样归功于Nguyen Quy Hy和这篇文章。

#5


2  

i had the same problem while creating user through entityframework and i found the solution and fix the problem by doing following steps

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

  1. Stop LavasoftTcpService64 service from services and
  2. 从服务和服务中停止LavasoftTcpService64服务
  3. Uninstall the web-companion from program and features and it started working in case if the problem still exist restart your machine hope it will help.
  4. 从程序和功能中卸载Web伴侣,如果问题仍然存在,它开始工作重新启动您的机器希望它会有所帮助。

#6


1  

I Just encountered this error myself and option #2 from here helped me.

我自己刚刚遇到这个错误,从这里选择#2帮助了我。

  1. Please, start Command Prompt as an administrator by right-clicking it and select Run as administrator.

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

  2. Enter this command to reset the network adapter (end with the Enter key):
    netsh winsock reset

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

  3. Restart the computer.

    重启电脑。

  4. Please, delete these two files:
    C:\WINDOWS\system32\LavasoftTcpService64.dll C:\WINDOWS\SysWOW64\LavasoftTcpService.dll (only for 64-bit Windows)

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

I renamed the files instead of deleting.

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