Skip to content

Commit a317f94

Browse files
committed
WinForms - NullReferenceException in ChromiumWebBrowser.OnHandleDestroyed
- Check browserHost is not null Resolves #3931
1 parent 8b6065d commit a317f94

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CefSharp.WinForms/ChromiumWebBrowser.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -523,9 +523,15 @@ private void OnHandleDestroyedInternal()
523523
parkingControl.CreateControl();
524524

525525
var host = this.GetBrowserHost();
526-
var hwnd = host.GetWindowHandle();
527526

528-
NativeMethodWrapper.SetWindowParent(hwnd, parkingControl.Handle);
527+
// Possible host is null
528+
// https://github.com/cefsharp/CefSharp/issues/3931
529+
if (host != null)
530+
{
531+
var hwnd = host.GetWindowHandle();
532+
533+
NativeMethodWrapper.SetWindowParent(hwnd, parkingControl.Handle);
534+
}
529535
}
530536
}
531537

0 commit comments

Comments
 (0)