VS Crashes upon exit

I've been having the following problem since B1 and I was hopping it would go away in B2 but it didn't. Here it goes:

I have a control designer (Windows Forms Control) that makes a call to the following code from a Verb:

internal static void ShowURL (string url)

{

WebBrowser browser = new WebBrowser();

browser.Navigate(url,true);

}

This works fine, a new browser is created, the pages is shown and everything is fine and dandy, that is untill I try to close Visual Studio, it seems that thebrowser object (even though the browser window was closed) is still alive.

Is this a bug  Can anybody suggest a workaround

Frank




Answer this question

VS Crashes upon exit

  • eayrider

    What exactly is occuring when VS closes Is a error message displayed How do you know the browser object still exists

    In the ShowURL method you are created a new WebBrowser control, but when are you disposing it

  • kavallo

    I am seeing this same "crash on exit" in VS2003 and understand that it has been a lingering bug for a while...
  • Eric Shan

    Dear David,

    Thank you for your response.

    VS Closes with the tipical message:

    " Microsoft Visual Studio has encountered a problem and needs to close.

    Send an error report to Microsoft
    "

    Yes, I am creating a new WebBrowser, I am never disposing it but I am not keeping a reference to it either (as you can see I have it in a local variable that goes out of scope right away).

    I do not want my action to be modal, I simply want the browser to open at a specific url and the let the user continue working normally either leaving the browser open or closing it at any time.

    I do not know if the browser object still exist, that was just a guess since I'm getting a crash that to me means tha something is staying alive after the browser is closed by the user. I get the same crash if I leave the browser windo opne and then close Visual Studio.

    Frank

  • e-milio

    Frank,

    The WebBrowser is going out of scope, however, unlike C++, that doesn't cause it to be released straight away. You really should call Dispose after you have used it.

    Any object that implements IDisposable, should have its associated Dispose method called. You shouldn't let these be finalized by the Garbarge Collector as this not only hurts performance, it also causes any resources the object owns to be held on longer than if had simply called Dispose.

    Are you sure that its the WebBrowser control that's causing the problem Have you tried commenting out the where you create the WebBrowser to see if it is something else

  • Everett

    Frank, this sounds like a bug.  Please use the MSDN product feedback center to log it.

    http://lab.msdn.microsoft.com/ProductFeedback/

    thanks
     - mike

  • syperk

    Changing the Url of the WebBrowser-Objekt to null when the "FormClosing"-Event is fired seems to be the easiest way to get rid of the problem...
  • Max Norris

    Will do. Thanks mike

  • Mirrie

    > The WebBrowser is going out of scope, however, unlike C++, that doesn't cause it to be released straight away. You really should call Dispose after you have used it.

    I'm aware of that (I've been a control developer since before v1), but since the browser window is comming up as a modeless window, I don't know when the user closes it, shouldn't it be disposed on its own when you hit the close button Besides I want to let my users to open as many browsers as they want and close them whenever they want. I shouldn't be keeping track of of these open browsers, besides what if the user decides to close Visual Stuido before closing the browsers.


    > Are you sure that its the WebBrowser control that's causing the problem

    Yes. You can reproduce this very easy, simply create a windows control, create a designer for it, attach a verb that call the function I posted and then close visual studio.


  • VS Crashes upon exit