Object reference not set to an instance of an object when close with two cefsharp.winforms instances

0

My wpf uses two ChromiumWebBrowser(Cefsharp.Winforms) instances, one is for my website, one is for displaying pdf file, when I close the MianWindow, there is a crash like below:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=CefSharp.WinForms
  StackTrace:
   在 CefSharp.WinForms.ChromiumWebBrowser.InternalDispose(Boolean disposing)
   在 CefSharp.WinForms.ChromiumWebBrowser.Dispose(Boolean disposing)
   在 System.ComponentModel.Component.Dispose()
   在 System.Windows.Forms.Control.Dispose(Boolean disposing)
   在 System.Windows.Forms.Integration.WinFormsAdapter.Dispose(Boolean disposing)
   在 System.ComponentModel.Component.Dispose()
   在 System.Windows.Forms.Integration.WindowsFormsHost.Dispose(Boolean disposing)
   在 System.Windows.Interop.HwndHost.WeakEventDispatcherShutdown.OnShutdownFinished(Object sender, EventArgs e)
   在 System.EventHandler.Invoke(Object sender, EventArgs e)
   在 System.Windows.Threading.Dispatcher.ShutdownImplInSecurityContext(Object state)
   在 System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   在 System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   在 MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   在 System.Windows.Threading.Dispatcher.ShutdownImpl()
   在 System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   在 System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   在 System.Windows.Application.RunDispatcher(Object ignore)
   在 System.Windows.Application.RunInternal(Window window)
   在 System.Windows.Application.Run(Window window)
   在 System.Windows.Application.Run()

I didn't set CefSharpSettings.ShutdownOnExit explicitly, in my close function, just call:

Application.Current.Shutdown();

It is ok if remove one for pdf. I host the browser in like below:

        <WindowsFormsHost Name="browserHost">
            <cefwpf:ChromiumWebBrowser x:Name="browser" IsBrowserInitializedChanged="browser_IsBrowserInitializedChanged">
            </cefwpf:ChromiumWebBrowser>
        </WindowsFormsHost>

My cefsharp version is 83.1.100 Thanks for any help!

cefsharp
asked on Stack Overflow Jun 28, 2020 by James Hao • edited Jun 28, 2020 by James Hao

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0