关闭WPF应用程序时发生间歇性NullReferenceException

时间:2012-08-29 09:12:04

标签: wpf winforms

我有一个WPF应用程序,其中第三方图表控件托管在WindowsFormsHost中。当应用程序关闭时,会间歇性地抛出NullReferenceException(大约每十个关闭一个)。

我们正在绘制图表上的实时数据。对于绘图,我们使用的是Control.Invoke

以下是异常的堆栈跟踪:

System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Media.MediaContext.RegisterICompositionTargetInternal(ICompositionTarget iv)
   at System.Windows.Interop.HwndTarget..ctor(IntPtr hwnd)
   at System.Windows.Interop.HwndSource.Initialize(HwndSourceParameters parameters)
   at System.Windows.Forms.Integration.ElementHost.OnHandleCreated(EventArgs e)
   at System.Windows.Forms.Control.WmCreate(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Integration.ElementHost.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

0 个答案:

没有答案