向大神求助 “System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生

时间:2022-01-31 20:28:57
调试的时候突然之间一连数据库就崩, 结果把连接单拉出来试试还是不行.我查了一下都说是代码的问题,可是我单独就写一句连接还是报错,不知道怎么解决,向大神求助啊!!!
代码就这一块
 SqlConnection con = new SqlConnection("Data Source=192.168.***.***;Initial Catalog=******;Password=***;Persist Security Info=FALSE;User ID=***");
            try
            {
                con.Open();
            }


“System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生 

其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

StackTrace:
       在 SNINativeMethodWrapper.SNIClose(IntPtr pConn)
       在 System.Data.SqlClient.SNIHandle.ReleaseHandle()
       在 System.Runtime.InteropServices.SafeHandle.InternalDispose()
       在 System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
       在 System.Runtime.InteropServices.SafeHandle.Dispose()
       在 System.Data.SqlClient.TdsParserStateObject.Dispose()
       在 System.Data.SqlClient.TdsParser.Disconnect()
       在 System.Data.SqlClient.SqlInternalConnectionTds.LoginFailure()
       在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
       在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
       在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.Open()
       在 WindowsFormsApplication2.Form1.button1_Click(Object sender, EventArgs e) 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:行号 26
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
       在 System.Windows.Forms.Button.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(Form mainForm)
       在 WindowsFormsApplication2.Program.Main() 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs:行号 19
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

17 个解决方案

#1


请重启一下sql 服务试试

#2


重启大法
  
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/

#3


服务器不归我管啊,而且别人用的时候也没事,还有没有其他思路

#4


重启你的机器

#5


引用 楼主 muqingyang_asp 的回复:
调试的时候突然之间一连数据库就崩, 结果把连接单拉出来试试还是不行.我查了一下都说是代码的问题,可是我单独就写一句连接还是报错,不知道怎么解决,向大神求助啊!!!
代码就这一块
 SqlConnection con = new SqlConnection("Data Source=192.168.***.***;Initial Catalog=******;Password=***;Persist Security Info=FALSE;User ID=***");
            try
            {
                con.Open();
            }


“System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生 

其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

StackTrace:
       在 SNINativeMethodWrapper.SNIClose(IntPtr pConn)
       在 System.Data.SqlClient.SNIHandle.ReleaseHandle()
       在 System.Runtime.InteropServices.SafeHandle.InternalDispose()
       在 System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
       在 System.Runtime.InteropServices.SafeHandle.Dispose()
       在 System.Data.SqlClient.TdsParserStateObject.Dispose()
       在 System.Data.SqlClient.TdsParser.Disconnect()
       在 System.Data.SqlClient.SqlInternalConnectionTds.LoginFailure()
       在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
       在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
       在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.Open()
       在 WindowsFormsApplication2.Form1.button1_Click(Object sender, EventArgs e) 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:行号 26
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
       在 System.Windows.Forms.Button.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(Form mainForm)
       在 WindowsFormsApplication2.Program.Main() 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs:行号 19
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: 


你安装过Visual Studio 2013 beta版本的吧。

#6


也遇到了同样的问题,有没有解决办法啊

#7


引用 5 楼 Danny_Su 的回复:
Quote: 引用 楼主 muqingyang_asp 的回复:

调试的时候突然之间一连数据库就崩, 结果把连接单拉出来试试还是不行.我查了一下都说是代码的问题,可是我单独就写一句连接还是报错,不知道怎么解决,向大神求助啊!!!
代码就这一块
 SqlConnection con = new SqlConnection("Data Source=192.168.***.***;Initial Catalog=******;Password=***;Persist Security Info=FALSE;User ID=***");
            try
            {
                con.Open();
            }


“System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生 

其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

StackTrace:
       在 SNINativeMethodWrapper.SNIClose(IntPtr pConn)
       在 System.Data.SqlClient.SNIHandle.ReleaseHandle()
       在 System.Runtime.InteropServices.SafeHandle.InternalDispose()
       在 System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
       在 System.Runtime.InteropServices.SafeHandle.Dispose()
       在 System.Data.SqlClient.TdsParserStateObject.Dispose()
       在 System.Data.SqlClient.TdsParser.Disconnect()
       在 System.Data.SqlClient.SqlInternalConnectionTds.LoginFailure()
       在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
       在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
       在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.Open()
       在 WindowsFormsApplication2.Form1.button1_Click(Object sender, EventArgs e) 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:行号 26
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
       在 System.Windows.Forms.Button.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(Form mainForm)
       在 WindowsFormsApplication2.Program.Main() 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs:行号 19
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: 


你安装过Visual Studio 2013 beta版本的吧。


确实安装了2013,不过我装的是正式版,也不行的

#8


我也是装了2013 出现了这个问题 什么情况呢?

#9


是vs2013的问题吧。
http://connect.microsoft.com/VisualStudio/feedback/details/806823/after-installing-vs-2013-unable-to-add-data-connections

#10


用管理员身份运行:netsh winsock reset
就可以解决。。
已经解决两次了。。。坑跌啊 

#11


引用 10 楼 Mockqi 的回复:
用管理员身份运行:netsh winsock reset
就可以解决。。
已经解决两次了。。。坑跌啊 
  通过此法可以解决

#12


向大神求助 “System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生
也可以下载最新的Net.Framework4.5.2,安装之后也可以解决~~

#13


引用 12 楼 u010853701 的回复:
向大神求助 “System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生
也可以下载最新的Net.Framework4.5.2,安装之后也可以解决~~


太棒了!解决数据库连接不上的问题。

#14


用管理员身份运行:netsh winsock reset
就可以解决。。
已经解决两次了。。。坑跌啊 

#15


用管理员身份运行:netsh winsock reset
就可以解决。。
每次启动都要运行,有没有一劳永逸的解决办法?

#16


刚刚那个命令可以了,网络问题,换个网络吧

#17


并不能解决问题

#1


请重启一下sql 服务试试

#2


重启大法
  
*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/

#3


服务器不归我管啊,而且别人用的时候也没事,还有没有其他思路

#4


重启你的机器

#5


引用 楼主 muqingyang_asp 的回复:
调试的时候突然之间一连数据库就崩, 结果把连接单拉出来试试还是不行.我查了一下都说是代码的问题,可是我单独就写一句连接还是报错,不知道怎么解决,向大神求助啊!!!
代码就这一块
 SqlConnection con = new SqlConnection("Data Source=192.168.***.***;Initial Catalog=******;Password=***;Persist Security Info=FALSE;User ID=***");
            try
            {
                con.Open();
            }


“System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生 

其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

StackTrace:
       在 SNINativeMethodWrapper.SNIClose(IntPtr pConn)
       在 System.Data.SqlClient.SNIHandle.ReleaseHandle()
       在 System.Runtime.InteropServices.SafeHandle.InternalDispose()
       在 System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
       在 System.Runtime.InteropServices.SafeHandle.Dispose()
       在 System.Data.SqlClient.TdsParserStateObject.Dispose()
       在 System.Data.SqlClient.TdsParser.Disconnect()
       在 System.Data.SqlClient.SqlInternalConnectionTds.LoginFailure()
       在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
       在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
       在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.Open()
       在 WindowsFormsApplication2.Form1.button1_Click(Object sender, EventArgs e) 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:行号 26
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
       在 System.Windows.Forms.Button.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(Form mainForm)
       在 WindowsFormsApplication2.Program.Main() 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs:行号 19
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: 


你安装过Visual Studio 2013 beta版本的吧。

#6


也遇到了同样的问题,有没有解决办法啊

#7


引用 5 楼 Danny_Su 的回复:
Quote: 引用 楼主 muqingyang_asp 的回复:

调试的时候突然之间一连数据库就崩, 结果把连接单拉出来试试还是不行.我查了一下都说是代码的问题,可是我单独就写一句连接还是报错,不知道怎么解决,向大神求助啊!!!
代码就这一块
 SqlConnection con = new SqlConnection("Data Source=192.168.***.***;Initial Catalog=******;Password=***;Persist Security Info=FALSE;User ID=***");
            try
            {
                con.Open();
            }


“System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生 

其他信息: 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。

StackTrace:
       在 SNINativeMethodWrapper.SNIClose(IntPtr pConn)
       在 System.Data.SqlClient.SNIHandle.ReleaseHandle()
       在 System.Runtime.InteropServices.SafeHandle.InternalDispose()
       在 System.Runtime.InteropServices.SafeHandle.Dispose(Boolean disposing)
       在 System.Runtime.InteropServices.SafeHandle.Dispose()
       在 System.Data.SqlClient.TdsParserStateObject.Dispose()
       在 System.Data.SqlClient.TdsParser.Disconnect()
       在 System.Data.SqlClient.SqlInternalConnectionTds.LoginFailure()
       在 System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
       在 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData)
       在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
       在 System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
       在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
       在 System.Data.SqlClient.SqlConnection.Open()
       在 WindowsFormsApplication2.Form1.button1_Click(Object sender, EventArgs e) 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Form1.cs:行号 26
       在 System.Windows.Forms.Control.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnClick(EventArgs e)
       在 System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
       在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       在 System.Windows.Forms.Control.WndProc(Message& m)
       在 System.Windows.Forms.ButtonBase.WndProc(Message& m)
       在 System.Windows.Forms.Button.WndProc(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       在 System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       在 System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       在 System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       在 System.Windows.Forms.Application.Run(Form mainForm)
       在 WindowsFormsApplication2.Program.Main() 位置 e:\testcode\WindowsFormsApplication2\WindowsFormsApplication2\Program.cs:行号 19
       在 System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
       在 System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       在 Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       在 System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       在 System.Threading.ThreadHelper.ThreadStart()
  InnerException: 


你安装过Visual Studio 2013 beta版本的吧。


确实安装了2013,不过我装的是正式版,也不行的

#8


我也是装了2013 出现了这个问题 什么情况呢?

#9


是vs2013的问题吧。
http://connect.microsoft.com/VisualStudio/feedback/details/806823/after-installing-vs-2013-unable-to-add-data-connections

#10


用管理员身份运行:netsh winsock reset
就可以解决。。
已经解决两次了。。。坑跌啊 

#11


引用 10 楼 Mockqi 的回复:
用管理员身份运行:netsh winsock reset
就可以解决。。
已经解决两次了。。。坑跌啊 
  通过此法可以解决

#12


向大神求助 “System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生
也可以下载最新的Net.Framework4.5.2,安装之后也可以解决~~

#13


引用 12 楼 u010853701 的回复:
向大神求助 “System.AccessViolationException”类型的未经处理的异常在 System.Data.dll 中发生
也可以下载最新的Net.Framework4.5.2,安装之后也可以解决~~


太棒了!解决数据库连接不上的问题。

#14


用管理员身份运行:netsh winsock reset
就可以解决。。
已经解决两次了。。。坑跌啊 

#15


用管理员身份运行:netsh winsock reset
就可以解决。。
每次启动都要运行,有没有一劳永逸的解决办法?

#16


刚刚那个命令可以了,网络问题,换个网络吧

#17


并不能解决问题