Restart a form that is disposed

0

A parent form starts a child form that embeds the Chromium Embedded Framework through CEFSharp. The user has the ability to close the child form. The user can restart the child form. When that happens the application terminates.

if (debugForm == null || debugForm.IsDisposed)
{
  if (debugForm != null && debugForm.IsDisposed)
  {
     debugForm = null;
  }
  debugForm = new CEFdebugger();
  ....
}

When the form has been run once, closed and restarted the line

debugForm = new CEFdebugger();

causes the application to terminate. In the output window I have

... has exited with code 1073741855 (0x4000001f)

According to this thread this indicates I should enable debugging unmanaged code, but that doesn't seem to have helped. In the FormClosing event for CEFdebugger I have added

private void CEFdebugger_FormClosing(object sender, FormClosingEventArgs e)
{
    Cef.Shutdown();
    this.Controls.Remove(browser);
    browser = null;
}

That hasn't helped. The application just terminates.

c#
cefsharp
asked on Stack Overflow Dec 16, 2015 by P Hemans • edited May 23, 2017 by Community

1 Answer

0

The problem was caused by the statement

Cef.Shutdown();

in CEFdebugger_FormClosing. By commenting it out and testing Cef.IsInitialized in the form constructor the problem was resolved.

answered on Stack Overflow Dec 16, 2015 by P Hemans

User contributions licensed under CC BY-SA 3.0