How to fix "The requested resource is in use. (Exception from HRESULT: 0x800700AA)"
Asked Answered
F

6

16

How can I solve this error?

"The requested resource is in use. (Exception from HRESULT: 0x800700AA)".

This appears while navigating to a different website using the WebBrowser control in C# .NET. Why?

Frigate answered 3/2, 2010 at 7:43 Comment(4)
How are you using the WebBrowser? Are you navigating via user interaction or programmatically? Could you post some code showing how the navigation is initialized?Corcyra
when do you get the arror? Is there any message box on the browser itself?Macrogamete
DocumentComplete is raised once per frame before a last time for the page. is there any frames on the page?Macrogamete
there's one page with 2 frames. is that the cause? how can i fix it?Frigate
B
14

The WebBrowser control is considered "in use" if either a navigation action is currently being processed, or any blocking dialog from the control is currently open (including context menu, Javascript alerts, NTLM login dialog, etc.). You can use the WebBrowser.IsBusy property to detect these states.

If due to a currently incomplete navigation action, you could try to stop the current navigation (if you indeed want to stop when the page is not completed loaded) or add the new navigation to a request queue and use a timer to wait until WebBrowser.IsBusy returns false.

If instead the busy state is due to one or more open blocking dialogs, you could do the same wait technique and perhaps Messagebox.Show() the user a message that pending navigation is delayed due to an open dialog window.

Banded answered 10/2, 2010 at 15:41 Comment(2)
How can we "stop the current navigation"?Aldosterone
@Aldosterone Refer WebBrowser.Stop Method and #6527376Matusow
P
4

I had this same issue. Calling WebBrowser.Stop() did not help, and WebBrowser.IsBusy never became false.

It turns out that if the page creates any sort of dialog (alert() popups, javascript errors, NTLM login popups etc.) you can't navigate away from the page until the dialog is closed.

My solution was to prevent the dialogs from showing in the first place. Apparently preventing all of these popups is simple; just set

webBrowser.ScriptErrorsSuppressed = true;
Paleobiology answered 16/12, 2013 at 13:48 Comment(3)
If you prevent NTLM login popups... doesn't that prevent the user from being able to get past a proxy, for example?Nucleoplasm
I confirmed that setting webBrowser.ScriptErrorsSuppressed = true will not show the NTLM login prompt. In our case, that meant we couldn't get past to proxy to hit an external website, so this solution didn't work for us.Nucleoplasm
This error can also occur if one attempts to set .DocumentText while the right-clicked context menu is currently opened. You can easily check for this state by checking WebBrowser.IsBusy property. It does correctly return False or True depending on whether the control is ready to accept new navigation or not (respectively).Countersink
F
2
bool go = false;
string SiteContent1 = string.Empty;
string SiteContent2 = string.Empty;
int index = 0;
WebBrowser wb = new  WebBrowser();

    void wb_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
    {

        try
        {
            if (go)
            {
                SiteContent2 = wb.DocumentText;
                // Code to compare to contents of the webbrowser
                index++;
                go = false;
                steps = 1;
            }

            if (!go)
                {

                    if (index >= TotalSiteCount)
                    {
                        Stop();
                    }
                    else if (steps == 1)
                    {
                        wb.Navigate(UrltocompareList[index].Url1);

                    }
                    else if (steps == 2)
                    {
                        SiteContent1 = wb.DocumentText;
                        wb.Navigate(UrltocompareList[index].Url2);
                        go = true;
                    }
                    steps++;                        
                }

        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);

        }

    }

UrltocompareList is a collection of 2 sites to compare.
TotalSiteCount is the number of items in UrltocompareList.
The form for this inherit IOleClientSite to remove media such as images, videos and no active X download to have a faster rendering time in webbrowser control.

I use this method instead of system.net.webclient to get the html of a webpage then compare them.
I got this error when it hits the wb.Navigate method.

Frigate answered 4/2, 2010 at 4:15 Comment(0)
B
1

An issue I ran into when running specflow tests with watin in windows 10 is that win10 by default uses MS Edge, so I had never opened IE, and when watin started it IE was stuck on the prompt for using default settings. Selecting options, closing browser and running tests again worked for me.

Just something to watch

Bijou answered 16/9, 2015 at 3:8 Comment(0)
M
0

This can be solved pretty easily. This error occurs when the browser commits an action while he's already performing an action. For example, you are navigating to some website while you rightclick in the web browser. To solve this, I did the follow:

//if my webbrowser isn't performing any actions
if(!myWebBrowser.IsBusy)
{
   //Navigate
   myWebBrowser.Navigate("http://www.google.com");
}
Mannikin answered 22/12, 2013 at 11:44 Comment(0)
C
-1

First Try

1- Please Check Navigate URL's (if you check, please check again compiled folder)

2- Delete WebBrowser Control and Add New

Me forget copy original file App.Path + "\error.html" and see this problem.

Guarantee Method

I Fix This Error in VB6

Add WebBrowserControl wb(0) (Name wb , Index=0)

And Before Ever Navigate

For i = 1 To wb.UBound

    Unload wb(i)

Next

Load wb(1)

wb(0).Visible = False

wb(1).Visible = true

wb(1).Navigate URL
Cobbler answered 19/8, 2015 at 13:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.