当前位置: 代码迷 >> .NET Framework >> C# WinForm窗体没有关闭自动运行Dispose()的有关问题
  详细解决方案

C# WinForm窗体没有关闭自动运行Dispose()的有关问题

热度:59   发布时间:2016-05-02 00:27:34.0
C# WinForm窗体没有关闭自动运行Dispose()的问题
如题,应用程序跑了几分钟到十几分钟不等,一点概率出现主窗体被Dispse()掉了,程序没有显示调用关闭之类的代码,也没有关闭窗体,突然到Application.Run(new Form())这里抛出异常:

C# code
   static class Program    {        private const int WS_SHOWNORMAL = 1;        private const int SW_RESTORE = 9;        /// <summary>        /// 应用程序的主入口点。        /// </summary>        [STAThread]        static void Main()        {                  //获取正在运行的进程            Process instance = RunningInstance();            if (instance == null)            {                DevExpress.UserSkins.BonusSkins.Register();                DevExpress.UserSkins.OfficeSkins.Register();                DevExpress.Skins.SkinManager.EnableFormSkins();                DevExpress.Skins.SkinManager.EnableMdiFormSkins();               // DevExpress.LookAndFeel.UserLookAndFeel.Default.SkinName = "Blue";                Application.EnableVisualStyles();                Application.SetCompatibleTextRenderingDefault(false);                Application.Run(MainForm.Instance);            }            else            {                HandleRunningInstance(instance);            }        }



异常不是每次都有的,异常信息为AccessViolationException 尝试读取或写入受保护的内存。这通常指示其他内存已损坏。


------解决方案--------------------
学习。。。
------解决方案--------------------
C# code
DevExpress.UserSkins.BonusSkins.Register();                DevExpress.UserSkins.OfficeSkins.Register();                DevExpress.Skins.SkinManager.EnableFormSkins();                DevExpress.Skins.SkinManager.EnableMdiFormSkins();
------解决方案--------------------
devexpress官方的解释:
A similar problem was fixed in the AccessViolationException occurs when using 24x24 Icons for toolbar images bug report. However, from the report's Version field, I see that you are already using the latest version
  相关解决方案