【发布时间】:2013-09-27 16:14:57
【问题描述】:
我收到了这个错误报告:
Collection is read only.
at System.Windows.Forms.SplitContainer.SplitContainerTypedControlCollection.SetChildIndexInternal(Control child, Int32 newIndex)
at System.Windows.Forms.Control.ControlCollection.SetChildIndex(Control child, Int32 newIndex)
at System.Windows.Forms.Control.UpdateChildControlIndex(Control ctl)
at System.Windows.Forms.Control.WmWindowPosChanged(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.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)
我不知道它是什么,搜索只是给了我一篇没有解决方案的 msdn 帖子。有任何想法吗?这个异常到底是关于什么的,如果我找到一些一般性的描述,我可能会找到解决它的方法?
【问题讨论】:
-
这是错误报告。代码有超过 10.000 行,这不会导致任何特定部分。所以问题是有人知道为什么会发生这种情况吗?
-
该错误表明您正在尝试从不允许此类操作的集合中分配或删除项目。很可能是
IEnumberable或类似的只读接口。 -
我意识到这一点,但是如何使用 SplitContainer 来完成呢?我的猜测是,这是 .net 中 SplitContainer 实现中的一些内部错误,但它仍然可能是由于某些原因而发生的,并且有办法解决它。
-
您可以找到所有对有问题的拆分容器的引用,并简单地发布与其相关的代码,例如构造函数和初始化。
-
SplitContainer 在代码中有 67 个引用。好的,这是可发布的,但不太可能有帮助。