Unhandled Exception when trying to read NativeHandle of a Eto.Forms.Form

public void AttachPopupToViewportWindow()
{
    _originalBound = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.Bounds;
    try
    {
        _formWindow = new SW.Win32Window(NativeHandle);
        General._viewportWindow.AddControl(_formWindow);
    }
    catch (System.ComponentModel.Win32Exception ex) 
    {
    }
}

When the above method is called repeatedly in a very short time, the NativeHandle cannot be read anymore and it throws an Unhandled Exception.

I tried different ways of bypassing this exception. They all failed to work. Why hasn’t the try-catch block catch the exception?

@dale @curtisw

Below are the exception log:

at MS.Win32.UnsafeNativeMethods.GetWindowTextLength(HandleRef hWnd)
at MS.Win32.UnsafeNativeMethods.GetWindowTextNoThrow(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.FireInvokeOnRenderCallbacks()
at System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)
at System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)
at System.Windows.Interop.HwndTarget.OnResize()
at System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Interop.HwndSource.HwndTargetFilterMessage(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)

Hi @Wiley,

Not much here to go on. Anything we can run so as to try to repeat?

– Dale