8

我已经为地产代理管理做了一个 c# 应用程序。

在那个应用程序中,我有一个 mdi 表单,其中包含所有菜单。

在该菜单中,当我选择 agent master 时,一个表单带有 Add agent 按钮。

单击“添加代理”按钮时,将打开另一个窗口,其中包含要填写的代理详细信息。

我的问题是>>当我关闭此表单时>>

"Attempt to read or write protected memory.This often an indication that other memory is corrupt"

错误来了。当我在此应用程序的消息框上单击确定时,整个应用程序将关闭。

当我通常通过 Visual Studio 运行应用程序时,不会出现此错误。

但是当我运行代码的exe时,就会出现这个错误。

这个错误有什么解决办法吗?

我在发布或调试项目时犯了错误吗?

我的堆栈跟踪:

See the end of this message for details on invoking 
just-in-time (JIT) debugging instead of this dialog box.

************** Exception Text **************
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)
   at System.Windows.Forms.Control.DefWndProc(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.TextBoxBase.WndProc(Message& m)
   at System.Windows.Forms.TextBox.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** Loaded Assemblies **************
mscorlib
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll
----------------------------------------
Anamol Estate
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///E:/Anamol%20Estate/Anamol%20Estate/Anamol%20Estate/bin/x86/Release/Anamol%20Estate.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Data
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll
----------------------------------------
System.Xml
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
System.Transactions
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll
----------------------------------------
System.EnterpriseServices
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll
----------------------------------------
System.Configuration
    Assembly Version: 2.0.0.0
    Win32 Version: 2.0.50727.5420 (Win7SP1.050727-5400)
    CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

启用 JIT 调试后,任何未处理的异常都将发送到计算机上注册的 JIT 调试器,而不是由该对话框处理。

4

2 回答 2

3

.NET Framework 也有类似的问题。试试这个修复

当您运行 Microsoft .NET Framework 2.0 Remoting 应用程序时,您可能会收到以下错误消息: Unhandled Exception: System.AccessViolationException: Attempted to read or write protected memory。这通常表明其他内存已损坏。此外,在运行某些类型的驱动程序软件或防病毒程序的计算机上的 .NET Framework 2.0 Remoting 应用程序中可能会出现此问题。

于 2012-10-10T18:43:12.143 回答
0

首先,您可以尝试memtest,因为您的内存中可能有一个特定的扇区在分配时会导致此错误。最新的当前版本是 4.2 下载部分是一个相当向下滚动。

或者

这发生在我身上一次,之前是由于病毒更改了我的 exe 文件中的标头。我已经格式化了我的电脑并重新安装了所有东西,在我的情况下它运行良好。我建议你试试这个选项。

于 2012-10-10T06:50:59.503 回答