c# - 索引超出范围...为什么会出现此错误?我不使用那个
问题描述
我收到错误... System.Collections.ArrayList.get_Item(Int32 index) 索引超出范围。必须是非负数且小于集合的大小
=================================================
Exception Desc >> Time[20180721_04:44:07] Message[Index was out of range. Must be non-negative and less than the size of the collection 매개 변수 이름: index] Source[mscorlib]StackTrace[ 위치: System.Collections.ArrayList.get_Item(Int32 index)
위치: System.Windows.Forms.ToolStripItemCollection.get_Item(Int32 index)
위치: System.Windows.Forms.ToolStrip.OnPaint(PaintEventArgs e)
위치: System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
위치: System.Windows.Forms.Control.WmPaint(Message& m)
위치: System.Windows.Forms.Control.WndProc(Message& m)
위치: System.Windows.Forms.ScrollableControl.WndProc(Message& m)
위치: System.Windows.Forms.ToolStrip.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)]
=================================================
为什么我得到这个错误???我不使用 System.Collections.ArrayList.get_Item(int32 Index)
这是我的源代码的一部分,错误点
private System.Windows.Forms.ToolStripLabel base_MessageBar;
...
public void MyFunctionAtErrorPoint(String str)
{
if (base_MessageBar.ForeColor != Color.Black) base_MessageBar.ForeColor= Color.Black;
this.base_MessageBar.Text = str;
}
环境上,我无法调试。***
发生率为 1/1000000 % ***
如果发生,窗口的 ToolStripLabel 会画一个“红色 X”***
解决方案
我通过使用调用函数解决了这个错误
我在非 UI 线程中设置了一些 UI 值...
我希望这篇文章对某人有帮助......
推荐阅读
- scala - 通过 SQL ALTER TABLE 命令向 Spark 表添加列
- c# - 绑定到用户控件的依赖属性
- java - 如何使用 AOP Spring 和 log4j 实现日志记录
- sql - 从 Sql server 中的 varbinary 字段中检索数据的性能问题
- php - 关闭之前后台进程中的 PHP CLI 进程由 laravel artisan 打开
- ruby-on-rails - Rails 在一个模型中使用 2 个公寓数据库
- javascript - 使用自定义过滤器时出现角度“未知提供者”错误
- python - IOError:[Errno 30] 只读文件系统:'geckodriver.log'
- asp.net - 为什么 DateTime lastdate 给出的日期与我尝试转换的日期不同?
- nasm - nasm 拒绝 fst tword [mem] --- 错误?