在随机情况下会发生system.runtime.interopservices.sehexception异常

时间:2018-11-15 05:40:31

标签: c# .net winforms exception-handling

我们有.net Windows应用程序,该应用程序有时由客户端运行。该应用程序有时会崩溃,并且每种情况都不同,但事件日志中的异常是相同的system.runtime.interopservices.sehexception未处理。我无法重现此问题。 这是堆栈跟踪:

Exception Info: System.Runtime.InteropServices.SEHException
   at SpectrumNZ.GUI.Modules.frmMainShell.Dispose(Boolean)
   at System.ComponentModel.Component.Finalize()

这是事件日志:

Faulting application name: SmartClient.exe, version: 0.0.0.0, time stamp: 0x5bb5f8a9
Faulting module name: clr.dll, version: 4.7.3130.0, time stamp: 0x5b175f1a
Exception code: 0xc0000006
Fault offset: 0x0007ca5b
Faulting process id: 0x1cac
Faulting application start time: 0x01d47c695f8665dc
Faulting application path: {path}\SmartClient.exe
Faulting module path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll
Report Id: 42f6b2d5-0936-4033-a6eb-edff18e8d7fa
Faulting package full name: 
Faulting package-relative application ID:

无法理解背后的问题是什么。经过一些搜索后,我发现这可能是网络问题,但我不确定。我有代码发生在哪里的更新问题

protected override void Dispose(bool disposing)
        {
            if (disposing )
            {
                FlushMemory();
                //--------------------------------------
                if (components != null)
                {
                    components.Dispose();
                }               

            }
            base.Dispose(disposing);
        }



[System.Runtime.InteropServices.DllImport("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize", ExactSpelling = true, CharSet = System.Runtime.InteropServices.CharSet.Ansi, SetLastError = true)]
        private static extern int SetProcessWorkingSetSize(IntPtr process, int minimumWorkingSetSize, int maximumWorkingSetSize);
        public static void FlushMemory()
        {
            GC.Collect();
            GC.WaitForPendingFinalizers();
            if (Environment.OSVersion.Platform == PlatformID.Win32NT)
            {
                SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
            }
        }

请帮助我找到导致此异常的原因。 谢谢

0 个答案:

没有答案