122
windows
C#程序ListBox崩溃问题
VS2012写的,Windows日志中的程序异常信息如下:
//--------------------------------------------------异常信息----------------------------------------------------//
日志名称: Application
来源: .NET Runtime
日期: 2017/8/16 17:45:06
事件 ID: 1026
任务类别: 无
级别: 错误
关键字: 经典
用户: 暂缺
计算机: CMP1-PC
描述:
应用程序: CMP.exe
Framework 版本: v4.0.30319
说明: 由于未经处理的异常,进程终止。
异常信息: System.NullReferenceException
堆栈:
在 System.Windows.Forms.ListBox+ItemArray.GetItem(Int32, Int32)
在 System.Windows.Forms.ListBox+ObjectCollection.RemoveAt(Int32)
在 CMP.EPD.UpdateEPDCommMessage(System.String)
在 CMP.EPD.AddEPDCommMessage(System.String)
在 CMP.EPD.Client_OnRead(System.Net.Sockets.Socket, System.String)
在 CMP.EPD_client.OnDataReceived(System.IAsyncResult)
在 System.Net.LazyAsyncResult.Complete(IntPtr)
在 System.Net.ContextAwareResult.CompleteCallback(System.Object)
在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
在 System.Net.ContextAwareResult.Complete(IntPtr)
在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
在 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
事件 Xml:
<Event xmlns="https://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name=".NET Runtime" />
<EventID Qualifiers="0">1026</EventID>
<Level>2</Level>
<Task>0</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2017-08-16T09:45:06.000000000Z" />
<EventRecordID>27800</EventRecordID>
<Channel>Application</Channel>
<Computer>CMP1-PC</Computer>
<Security />
</System>
<EventData>
<Data>
应用程序: CMP.exe
Framework 版本: v4.0.30319
说明: 由于未经处理的异常,进程终止。
异常信息: System.NullReferenceException
堆栈:
在 System.Windows.Forms.ListBox+ItemArray.GetItem(Int32, Int32)
在 System.Windows.Forms.ListBox+ObjectCollection.RemoveAt(Int32)
在 CMP.EPD.UpdateEPDCommMessage(System.String)
在 CMP.EPD.AddEPDCommMessage(System.String)
在 CMP.EPD.Client_OnRead(System.Net.Sockets.Socket, System.String)
在 CMP.EPD_client.OnDataReceived(System.IAsyncResult)
在 System.Net.LazyAsyncResult.Complete(IntPtr)
在 System.Net.ContextAwareResult.CompleteCallback(System.Object)
在 System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
在 System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
在 System.Net.ContextAwareResult.Complete(IntPtr)
在 System.Net.LazyAsyncResult.ProtectedInvokeCallback(System.Object, IntPtr)
在 System.Net.Sockets.BaseOverlappedAsyncResult.CompletionPortCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
在 System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32, UInt32, System.Threading.NativeOverlapped*)
</Data>
</EventData>
</Event>
//--------------------------------------------------异常信息----------------------------------------------------//
相关代码段如下,就是超过两百条之后移除第一条,根据高度计算显示最新的Listbox条目。
private void UpdateEPDCommMessage(string msg)
{
while (lbx_EPD_Comm.Items.Count > 200)
lbx_EPD_Comm.Items.RemoveAt(0);
lbx_EPD_Comm.Items.Add(msg);
if (lbx_EPD_Comm.Items.Count >= (lbx_EPD_Comm.Height / lbx_EPD_Comm.ItemHeight))
{
lbx_EPD_Comm.TopIndex = lbx_EPD_Comm.Items.Count - (int)(lbx_EPD_Comm.Height / lbx_EPD_Comm.ItemHeight) + 1;
}
}
请大家给看看,是哪出的问题。谢谢
最后更新:2017-08-18 17:02:29
上一篇:
关于Webm格式的问题
下一篇:
Microsoft账户人脉和outlook帐户人脉的关系能不能解释一下
你的设备已过期,并缺少重要的安全和质量更新,因此存在风险。让我们带你重回正轨,这样
Microsoft store 无法联网,显示Microsoft Store需要联网,你似乎没有联网
设备以迁移 由于仅部分匹配或匹配不明确,因此无法迁移设备
由于在创建转储期间出错,创建转储文件失败。
发生临时 DNS 错误
应用商店,在我们这边发生问题,无法使你登陆,错误代码: 0xD000000D
照相机不可用,错误代码:0xA00F4244(0xC00DABE0)
应用商店打开异常提示“清单中指定了未知的布局”
自定义扫描Windows defender里面的设备性能和运行状况 黄色感叹号问题
windows预口体验成员内口版本遇到问题需要重启
热门内容
windows10 点开此电脑后,有两个显示硬盘盘符的目录是怎么回事?
windows 10 专业版无法下载中文语言包
KB4056892
win10不能共享文件夹
在Surfacebook上用Windows to go 1703版本,更新后重启蓝屏,无法进入系统
windows10 1709版本更新失败,错误0x8007001f
microdoft visual c++ 2015 redistributable
WIN10 Insider Preview 17025更新失败,错误代码0x80096004
计算机管理服务 出现一个内部错误(INVALID
关于控制面板中的安全和维护内提示Windows defender 防病毒已关闭的问题