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

VS Crashes upon exit
eayrider
In the ShowURL method you are created a new WebBrowser control, but when are you disposing it
kavallo
Eric Shan
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
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
http://lab.msdn.microsoft.com/ProductFeedback/
thanks
- mike
syperk
Max Norris
Mirrie
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.