我们的应用程序经历了奇怪的致命System.AccessViolationException。当我们将AppDomain.CurrentDomain.UnhandledException事件配置为记录异常时,我们看到了这些。
Exception: System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Bootstrap.Run() in e:\build-dir\src\Bootstrap.cs:line 25异常本身似乎不包含“试图读取或写入受保护内存”的信息,这通常表明其他内存已损坏。
更新
发布于 2015-06-04 22:03:09
我也有类似的问题,不像@BartRead,一直如此。对我来说,一些CLI代码在一个简单的windows窗体应用程序中工作得很好,但是当我把它放在一个大型插件生态系统(多线程)中时,需要使用Application.Run或Application.DoEvents来发送所需的消息。如果您能够访问正在运行的代码,最好的选择(对我起作用)是在维护功能的同时注释掉越来越多的代码片段。原来,我没有GC::Alloc的回调/委托,虽然被固定和仍然引用,但在内存中被移动,或者直接被标记为收集。
如果你使用GC的话,一定要自己清理干净!
https://stackoverflow.com/questions/5133971
复制相似问题