Windows Develop Bookmark and Share   
 index > Windows Forms General > Unhandled exception using webBrowser
 

Unhandled exception using webBrowser

when i use webbrowser control to navigate site above 4 times(with DocumentCompleted event). it would throwa unhandled access violation exception , and interrupt my program.

private void btnStart_Click(object sender, EventArgs e)
{
btnStart.Enabled = false;
try
{
LoadList();
if (listData.Count == 0 || listPwd.Count == 0)
return;
wdWork = listData[0];
webBrowser.Navigate("http://xxxxxxx.com");
}
catch (Exception ex)
{
SingletonProvider<CLog>.Instance.Add(ex.Message, "StartWorking", "Error");
}
}

private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
try
{
WebBrowser webBrowser = (WebBrowser)sender;
if (webBrowser.Url.ToString() != "http://xxxxxxx.com")
{
if (webBrowser.Url.ToString().Contains("http://xxxxxxx.com/error.asp"))
{
wdWork.AddStatus();
NextProcess();
}
return;
}
//Do something.

if (false == (bool)webBrowser.Document.InvokeScript("Submit_onclick"))
NextProcess();
}
catch (Exception ex)
{
NextProcess();
}
}

private void NextProcess()
{
int wdIndex = wdWork.Index + 1;
if (wdIndex >= listData.Count)
{
wdIndex = 0;
}
while (listData[wdIndex].GetStatus() >= listPwd.Count - 1)
{
wdIndex++;
if (wdIndex >= listData.Count)
wdIndex = 0;
if (wdIndex == wdWork.Index)
return;
}
wdWork.Password = listPwd[wdWork.GetStatus() + 1];
wdWork = listData[wdIndex];
webBrowser.Navigate("http://xxxxxxx.com");
}

Readon  Thursday, March 30, 2006 6:30 AM
What is the url for the 4th document? What is the Exception message? What is the Stack-trace?

Can you provide a little more information, thanks!
Pieter Joost van de Sande  Thursday, March 30, 2006 3:18 PM

You can use google to search for other answers

Custom Search

More Threads

• class object type cast issue
• How to drag & drop shape drawn by GDI in picture box area?
• problem with Configuration files and windows services
• control, usercontrol, panel
• Add listview group question
• Multiple Forms / Calling a Single Form from the Code
• Windows form keeps dissappearing
• Prevent text wrapping in text properties
• UserControl focus question
• RichTextBox not displaying Word rtf file properly