Disable WebBrowser control due to swallowing exceptions

I use System.Windows.Forms.WebBrowserto open a-la Visual Studio Start Page. However, it seems that the control captures and processes all exceptions, silently sinking them! Needless to say, this is a very bad behavior.

void webBrowserNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
    // WebBrowser.Navigating event handler
    throw new Exception("OMG!");
}

The above code cancels the navigation and swallows the exception.

void webBrowserNavigating(object sender, WebBrowserNavigatingEventArgs e)
{
    // WebBrowser.Navigating event handler
    try
    {
        e.Cancel = true;
        if (actions.ContainsKey(e.Url.ToString()))
        {
            actions[e.Url.ToString()].Invoke(e.Url, webBrowser.Document);
        }
    }
    catch (Exception exception)
    {
        MessageBox.Show(exception.ToString());
    }
}

So, what I am doing (above) is catching all exceptions and a window pops up, it is better than silence, but still clearly far from ideal. I would like it to redirect the exception through the normal application crash path, so that it eventually becomes unprocessed or handled by the application from the root.

WebBrowser ? - ?

+3
2

, , - , . .

.

0

, , script. script browser.ScriptErrorsSuppressed.

, script, - , ? , .

,

+1

Source: https://habr.com/ru/post/1696460/


All Articles