我有一个 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)