Why a RaceOnRCWCleanup error when closing a form with WebBrowser control on it?

Viewed 27720

VS2008, .NET 2, VB.NET, XP ...

I have a Windows form, with a WebBrowser control and a Close button, which just does a Me.Close. The form's cancel button is set to the Close button, so that I can hit ESC to close the form.

I set the DocumentText property of the WebBrowser control in the load event, and the HTML displays.

Running the application from Visual Studio, if I click the Close button, the form closes with no error.

If I hit the ESC button I get

RaceOnRCWCleanup was detected Message: An attempt has been made to free an RCW that is in use. The RCW is in use on the active thread or another thread. Attempting to free an in-use RCW can cause corruption or data loss.

If I run the app outside VS, I get no error.

Any ideas a) why the error, and b) how to prevent or suppress it?

Many thanks in advance.

1 Answers
Related