C# 如何修复“请求的资源正在使用中。(来自 HRESULT 的异常:0x800700AA)”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2190390/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to fix "The requested resource is in use. (Exception from HRESULT: 0x800700AA)"
提问by Jepe d Hepe
How can I solve this error?
我该如何解决这个错误?
"The requested resource is in use. (Exception from HRESULT: 0x800700AA)".
“请求的资源正在使用中。(来自 HRESULT 的异常:0x800700AA)”。
This appears while navigating to a different website using the WebBrowser control in C# .NET. Why?
使用 C# .NET 中的 WebBrowser 控件导航到不同的网站时会出现这种情况。为什么?
采纳答案by u109919
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.
如果当前正在处理导航操作,或者当前打开了来自该控件的任何阻止对话框(包括上下文菜单、Javascript 警报、NTLM 登录对话框等),则认为 WebBrowser 控件“正在使用”。您可以使用该WebBrowser.IsBusy
属性来检测这些状态。
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.
如果由于当前未完成的导航操作,您可以尝试停止当前导航(如果您确实想在页面未完成加载时停止)或将新导航添加到请求队列并使用计时器等待直到WebBrowser.IsBusy
返回 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.
相反,如果忙碌状态是由于一个或多个打开的阻塞对话框造成的,您可以执行相同的等待技术,并且可能会Messagebox.Show()
向用户发送一条消息,即由于打开的对话框窗口而延迟导航。
回答by Jepe d Hepe
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.
UrltocompareList 是要比较的 2 个站点的集合。
TotalSiteCount 是 UrltocompareList 中的项目数。
此表单继承 IOleClientSite 以删除图像、视频等媒体,并且没有活动的 X 下载,以便在 webbrowser 控件中具有更快的渲染时间。
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.
我使用这种方法而不是 system.net.webclient 来获取网页的 html 然后比较它们。
当它遇到 wb.Navigate 方法时,我收到了这个错误。
回答by BlueRaja - Danny Pflughoeft
I had this same issue. Calling WebBrowser.Stop()
did not help, and WebBrowser.IsBusy
never became false.
我有同样的问题。打电话WebBrowser.Stop()
没有帮助,WebBrowser.IsBusy
永远不会变成假的。
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.
事实证明,如果页面创建了任何类型的对话框(alert()
弹出窗口、javascript 错误、NTLM 登录弹出窗口等),您将无法在对话框关闭之前离开该页面。
My solution was to prevent the dialogs from showing in the first place. Apparentlypreventing all of these popups is simple; just set
我的解决方案是首先防止对话框显示。 显然,阻止所有这些弹出窗口很简单;刚刚设置
webBrowser.ScriptErrorsSuppressed = true;
回答by eli
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:
这可以很容易地解决。当浏览器在执行操作时提交操作时会发生此错误。例如,当您在 Web 浏览器中单击鼠标右键时,您正在导航到某个网站。为了解决这个问题,我做了以下工作:
//if my webbrowser isn't performing any actions
if(!myWebBrowser.IsBusy)
{
//Navigate
myWebBrowser.Navigate("http://www.google.com");
}
回答by zersina
First Try
第一次尝试
1- Please Check Navigate URL's(if you check, please check again compiled folder)
1-请检查导航 URL(如果检查,请再次检查已编译的文件夹)
2- Delete WebBrowser Control and Add New
2- 删除 WebBrowser 控件并添加新控件
Me forget copy original file App.Path + "\error.html" and see this problem.
我忘记复制原始文件 App.Path + "\error.html" 并看到这个问题。
Guarantee Method
担保方式
I Fix This Error in VB6
我在 VB6 中修复了这个错误
Add WebBrowserControl wb(0) (Name wb , Index=0)
添加 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
回答by BlackICE
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.
我在 Windows 10 中使用 watin 运行 specflow 测试时遇到的一个问题是,win10 默认使用 MS Edge,所以我从未打开过 IE,当 watin 启动时,IE 卡在使用默认设置的提示上。选择选项,关闭浏览器并再次运行测试对我有用。
Just something to watch
只是要看的东西