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

muqingyang_asp 2013-10-17 03:44:45
调试的时候突然之间一连数据库就崩, 结果把连接单拉出来试试还是不行.我查了一下都说是代码的问题,可是我单独就写一句连接还是报错,不知道怎么解决,向大神求助啊!!!
代码就这一块
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:
...全文
14671 17 打赏 收藏 转发到动态 举报
写回复
用AI写文章
17 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_31521823 2016-06-30
  • 打赏
  • 举报
回复
并不能解决问题
程序小鸟XXX 2015-04-13
  • 打赏
  • 举报
回复
刚刚那个命令可以了,网络问题,换个网络吧
wudirqa 2015-01-30
  • 打赏
  • 举报
回复
用管理员身份运行:netsh winsock reset 就可以解决。。 每次启动都要运行,有没有一劳永逸的解决办法?
lwplvx 2014-07-08
  • 打赏
  • 举报
回复
用管理员身份运行:netsh winsock reset 就可以解决。。 已经解决两次了。。。坑跌啊
牛迁迁 2014-06-06
  • 打赏
  • 举报
回复
引用 12 楼 u010853701 的回复:
也可以下载最新的Net.Framework4.5.2,安装之后也可以解决~~
太棒了!解决数据库连接不上的问题。
令仔很忙 2014-06-04
  • 打赏
  • 举报
回复

也可以下载最新的Net.Framework4.5.2,安装之后也可以解决~~
JavaWangYue 2014-04-14
  • 打赏
  • 举报
回复
引用 10 楼 Mockqi 的回复:
用管理员身份运行:netsh winsock reset 就可以解决。。 已经解决两次了。。。坑跌啊
通过此法可以解决
  • 打赏
  • 举报
回复
用管理员身份运行:netsh winsock reset 就可以解决。。 已经解决两次了。。。坑跌啊
众链网络 2013-11-15
  • 打赏
  • 举报
回复
是vs2013的问题吧。 http://connect.microsoft.com/VisualStudio/feedback/details/806823/after-installing-vs-2013-unable-to-add-data-connections
xinzhyu 2013-11-05
  • 打赏
  • 举报
回复
我也是装了2013 出现了这个问题 什么情况呢?
sunwow 2013-10-30
  • 打赏
  • 举报
回复
引用 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版本的吧。[/quote] 确实安装了2013,不过我装的是正式版,也不行的
sunwow 2013-10-30
  • 打赏
  • 举报
回复
也遇到了同样的问题,有没有解决办法啊
Danny_Su 2013-10-29
  • 打赏
  • 举报
回复
引用 楼主 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版本的吧。
feiyun0112 2013-10-17
  • 打赏
  • 举报
回复
重启你的机器
muqingyang_asp 2013-10-17
  • 打赏
  • 举报
回复
服务器不归我管啊,而且别人用的时候也没事,还有没有其他思路
feiyun0112 2013-10-17
  • 打赏
  • 举报
回复
重启大法

*****************************************************************************
签名档: http://feiyun0112.cnblogs.com/
QuickPai 2013-10-17
  • 打赏
  • 举报
回复
请重启一下sql 服务试试

110,539

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧