尝试读取或写入受保护的内存 - Sql Compact 和 .NEt
我尝试在两种情况下运行该应用程序:安装了 SQL Server 精简版 (3.5),一种没有安装。未安装 SQL Server Compact 版本时,出现以下错误:
Exception :Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
Inner Exception :
========================
Stack Trace :
========================
at System.Data.SqlServerCe.NativeMethods.CloseStore(IntPtr pSeStore)
at System.Data.SqlServerCe.SqlCeConnection.ReleaseNativeInterfaces()
at System.Data.SqlServerCe.SqlCeConnection.Dispose(Boolean disposing)
at System.Data.SqlServerCe.SqlCeConnection.Finalize()
Source :
========================
System.Data.SqlServerCe
----------------------------------------------------------
我正在使用 这个方法。
我从 Windows 窗体启动的控制台应用程序收到此错误。在这两个应用程序中,我都插入了未处理的异常编码,它正在执行并返回到文本文件,并且生成了 Microsoft“报告错误”对话框;我该如何防止这种情况发生?如何解决导致此问题的原因?
I've tried to run the application in two situations: with SQL Server compact edition (3.5) installed and one without. When SQL Server Compact edition isn't installed, I get the following error:
Exception :Attempted to read or write protected memory. This is often an indication
that other memory is corrupt.
Inner Exception :
========================
Stack Trace :
========================
at System.Data.SqlServerCe.NativeMethods.CloseStore(IntPtr pSeStore)
at System.Data.SqlServerCe.SqlCeConnection.ReleaseNativeInterfaces()
at System.Data.SqlServerCe.SqlCeConnection.Dispose(Boolean disposing)
at System.Data.SqlServerCe.SqlCeConnection.Finalize()
Source :
========================
System.Data.SqlServerCe
----------------------------------------------------------
I'm handling Unhandled exceptions using this method.
I am getting this error from a console application which I'm starting from a Windows Form. In both the application I've inserted the Unhandled Exception coding and it's getting executed and getting returned to the text file, and the Microsoft 'report error' dialog is getting generated; how do I keep that from happening? How do I troubleshoot what is causing this issue?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当我遇到此问题时,问题出在数据库连接上:
如果在重新打开连接之前未关闭连接,则会在“
System.Data.SqlServerCe
”周围出现此错误。只需添加这一行就解决了我的问题:
When I had this issue, the problem was the database connection:
If you don't close the connection before reopen it, you get this error arround "
System.Data.SqlServerCe
".Just adding this line solved my issue:
本机 SQL Compact 代码正在崩溃。这很不寻常。并且非常不太可能是由您的代码引起的。这不是您可以调试的问题,您除了机器代码之外没有任何东西可以查看。如果您运行任何其他进程内非托管代码,则认为它是造成不稳定的原因。注销电脑并将其射入磁盘盘片是快速解决方法。
The native SQL Compact code is crashing. That's very unusual. And very unlikely to be caused by your code. Not the kind of problem you could ever debug, you don't have anything but machine code to look at. If you run any other in-process unmanaged code then consider it to be responsible for the instability. Writing off the PC and shooting it between the disk platters is the quick fix.
我自己的错误是由于我使用线程而引起的。检查此链接
My own error was being caused by the fact that I was using threads. Check this link
我解决了那个错误!!!这并不是真正的 SqlCompact 错误或代码异常。这是 GAC 抛出的,因为我出于某种目的打开了另一个应用程序,并且该应用程序正在访问数据库。当该应用程序关闭数据库时,它被显式地从父应用程序中杀死,因此 SQL COMPACT 出现错误。所以我对我的代码做了一些更改,它现在可以工作了!感谢您的所有建议。
I solved that error!!! It was not really SqlCompact error or Exception from code.It was GAC that was throwingit bec I was opening another application for some purpose and that app was accessing the Database. At time when that app was closing the DB it was explicitly getting killed from the parent app so the error was coming for SQL COMPACT. so I ,ade few changes in my code and it's working now!!! Thanks for all your suggestions.