抛出task . throwifexception的异常是什么?
本文关键字:是什么 异常 task throwifexception 抛出 | 更新日期: 2023-09-27 18:12:18
我有一个windows窗体应用程序开发与c#和。net Framework 4.0运行任务。
我很抱歉问这个问题,但我不知道哪里出现了异常。这是堆栈跟踪:
One or more errors occurred.
at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
at MyCompany.Dispositivos.Plugins.TICAnKorr.DeviceTICAnKorr.StopLive()
at MyCompany.Dispositivos.Plugins.TICAnKorr.VisorTICAnKorrMini.StopRemote()
at MyCompany.Dispositivos.InterfazDispositivos.ICBaseVisor.DesasociarDispositivo()
at MyCompany.Dispositivos.InterfazDispositivos.ControlMosaico.DesasociarTodosLosPaneles()
at MyCompany.Dispositivos.InterfazDispositivos.ControlMosaico.CrearControlSeleccionado(DeviceBase device)
at MyCompany.Dispositivos.InterfazDispositivos.ControlMosaico.icPanelViewer_MouseDown(Object sender, MouseEventArgs e)
at System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.UserControl.OnMouseDown(MouseEventArgs e)
at MyCompany.Dispositivos.InterfazDispositivos.VisorDeMosaico.mousedown(Object sender, MouseEventArgs e)
at System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.UserControl.OnMouseDown(MouseEventArgs e)
at MyCompany.BasicInterface.Controles_Basicos.ICLabel.lblText_MouseDown(Object sender, MouseEventArgs e)
at System.Windows.Forms.Control.OnMouseDown(MouseEventArgs e)
at System.Windows.Forms.Control.WmMouseDown(Message& m, MouseButtons button, Int32 clicks)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.Label.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)
Object reference not set to an instance of an object.
at MyCompany.Dispositivos.Plugins.TICAnKorr.VisorTICAnKorrMini.MensajeEstado()
at MyCompany.Dispositivos.Plugins.TICAnKorr.VisorTICAnKorrMini.m_DispositivoAsociado_NewResult(Object sender)
at MyCompany.Dispositivos.ConexionesDispositivos.NewResultsEventHandler.Invoke(Object sender)
at MyCompany.Dispositivos.ConexionesDispositivos.DeviceBase.OnNewResult()
at MyCompany.Dispositivos.Plugins.TICAnKorr.DeviceTICAnKorr.HiloCaptura()
at MyCompany.Dispositivos.ConexionesDispositivos.DeviceBase.<StartLive>b__9()
at System.Threading.Tasks.Task.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
我认为抛出的异常是:
Object reference not set to an instance of an object.
at MyCompany.Dispositivos.Plugins.TICAnKorr.VisorTICAnKorrMini.MensajeEstado()
真正的例外是什么?
如果这里不是问这个问题的合适的地方,请告诉我,我删除它。
我不是在问Object reference not set to an instance of an object.
的意义是什么,我知道,我是在问这个异常是否使任务抛出System.Threading.Tasks.Task.ThrowIfExceptional
。
当您执行返回Task
的操作时,任何异常都会存储在任务的Task.Exception
属性中。
当调用Wait
时,代码等待任务完成,然后重新抛出在AggreagtedException
中发生的任何异常。因此,ThrowIfExceptional
方法在任务完成后被调用,以引发发生的任何异常。
所以问题很可能是在任何代码被执行返回正在等待的任务的空引用。应该是里面的东西:
MyCompany.Dispositivos.Plugins.TICAnKorr.DeviceTICAnKorr.StopLive()
这可能是因为你的类中的一些变量是空的,它也没有被处理。我知道你说过你知道这个错误,但是最近我遇到了这个错误,我的解决办法是把算子'?