Quantcast
Channel: Active questions tagged crash - Stack Overflow
Viewing all articles
Browse latest Browse all 7188

random crash in WPF application : "Invalid index at MS.Win32.UnsafeNativeMethods.GetWindowText(...)"

$
0
0

We experience following crash at random moments in our WPF application :

 Invalid index at MS.Win32.UnsafeNativeMethods.GetWindowText(HandleRef hWnd, StringBuilder lpString, Int32 nMaxCount)   at System.Windows.Automation.Peers.WindowAutomationPeer.GetNameCore()   at System.Windows.Automation.Peers.AutomationPeer.UpdateSubtree()   at System.Windows.ContextLayoutManager.fireAutomationEvents()   at System.Windows.ContextLayoutManager.UpdateLayout()   at System.Windows.ContextLayoutManager.UpdateLayoutCallback(Object arg)   at System.Windows.Media.MediaContext.InvokeOnRenderCallback.DoWork()   at System.Windows.Media.MediaContext.FireInvokeOnRenderCallbacks()   at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)   at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)   at System.Windows.Threading.DispatcherOperation.InvokeImpl()   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)   at MS.Internal.CulturePreservingExecutionContext.CallbackWrapper(Object obj)   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)   at System.Windows.Threading.DispatcherOperation.Invoke()   at System.Windows.Threading.Dispatcher.ProcessQueue()   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)   at System.Windows.Application.RunDispatcher(Object ignore)   at System.Windows.Application.RunInternal(Window window)   at System.Windows.Application.Run(Window window)   at System.Windows.Application.Run()

Most of the time the crash occurs on any call to "ShowDialog()" in the WPF code, sometimes also on other calls (unclear which exactly, the stack trace just mentions the top-level "Application.Run()")

The problem starts occurring randomly after having accessed some javascript code in a CefSharp embedded browser component, which adds WebRTC streaming functionality to the WPF application. The crashes stopped occurring as soon as we replaced the CefSharp component with Microsofts WebView2 component.

On a few occasions in the past we encountered the exact same random crash when our WPF application was running alongside 2 other third party applications :

  • a "TabletInputService", part of Smart Technologies whiteboard software
  • a screen capture driver ("VHScrCap" of Split Media Labs)

At that moment we found that the crash even occurred in a dummy WPF test application which contained nothing but 1 "ShowDialog()" call. This lead us to the conclusion that we could change nothing in our WPF application code to avoid the crashes. Only "solution" was to replace above screen capture driver with the DirectShow "screen-capture-recorder"

My question is : what could be the root cause of this window handle corruption, and what could we do to avoid the resulting crashes in a WPF application?


Viewing all articles
Browse latest Browse all 7188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>