【问题标题】:Application exception with windows xpwindows xp的应用程序异常
【发布时间】:2013-09-02 05:46:01
【问题描述】:

我有一个可以在 Windows 7 上运行的 C# 应用程序,但不能在 Windows XP 上运行。当我尝试关闭程序窗口时程序崩溃。窗口关闭时没有任何额外的功能,父窗口也不等待任何结果。

这是一个例外:

System.InvalidOperationException:集合已修改;枚举操作可能无法执行。
在 System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource 资源)
在 System.Collections.Generic.List1.Enumerator.MoveNextRare()
at System.Collections.Generic.List
1.Enumerator.MoveNext()
在 Microsoft.VisualBasic.PowerPacks.ShapeCollection.Dispose(布尔处理)
在 Microsoft.VisualBasic.PowerPacks.ShapeContainer.Dispose(布尔处理)
在 System.ComponentModel.Component.Dispose()
在 System.Windows.Forms.Control.Dispose(布尔处理)
在 System.Windows.Forms.Form.Dispose(布尔处理)
在 c:\Users\PC_Jeff_1\Desktop\sensors_file1\DataManagerv3.1\EmailSettingsForm.Designer.cs:第 24 行中的 DataManager.EmailSettingsForm.Dispose(Boolean disposing)
在 System.Windows.Forms.Form.WmClose(Message&m)
在 System.Windows.Forms.Form.WndProc(Message&m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

【问题讨论】:

  • 您能重新格式化那堵随机文字墙吗?
  • 请将Dispose(bool disposing)方法中的代码包含在c:\Users\PC_Jeff_1\Desktop\sensors_file1\DataManagerv3.1\EmailSettingsForm.Designer.cs
  • protected override void Dispose(bool disposing) { if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); }

标签: c# windows-7 windows-xp


【解决方案1】:

我在 dispose 中添加了 try 块,并且不再有这个问题,但我想问题仍然存在。

块:

    protected override void Dispose(bool disposing)`
    {
        try
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }
            }
            base.Dispose(disposing);
        }
        catch
        {

        }
    }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-16
    • 2015-01-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    相关资源
    最近更新 更多