A WebBrowser control application hangs after changing the screen resolution in Internet Explorer 9

Applies to: Internet Explorer 9

Symptoms


Consider the following scenario. You have a Microsoft .NET web application that uses a WebBrowser control, and in it you try to execute code similar to the following:

MyWebBrowser.Visible = false;
MyWebBrowser.Navigate("about:blank");
MyWebBrowser.Document.Write(String.Empty);

If you use Windows Internet Explorer 9 to browse to the web application page that hosts the control, and then you change the screen resolution (for example launching a full screen application such as a game), the web page hosting the control will become unresponsive.


Cause


This problem occurs because MSHTML.dll keeps sending WM_APP + 2 messages to the application.


Workaround



To workaround this issue, modify the WebBrowser control code so it looks similar to the following:

MyWebBrowser.Visible = false;
MyWebBrowser.Navigate("about:blank");
MyWebBrowser.Document.Write("<HTML><BODY></BODY></HTML>");