问题
I've got the following code, but when I Build it I get an error on WebBrowserDocumentCompletedEventArgs telling me the type or namespace could not be found.
I've been searching the web and attempting to add DLLs for over an hour. Can anyone help?
private void b_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WebBrowser b = sender as WebBrowser;
string response = b.DocumentText;
// looks in the page source to find the authenticity token.
// could also use regular exp<b></b>ressions here.
int index = response.IndexOf("authenticity_token");
int startIndex = index + 41;
string authenticityToken = response.Substring(startIndex, 40);
// unregisters the first event handler
// adds a second event handler
b.DocumentCompleted -= new WebBrowserDocumentCompletedEventHandler(b_DocumentCompleted);
b.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(b_DocumentCompleted2);
// format our data that we are going to post to the server
// this will include our post parameters. They do not need to be in a specific
// order, as long as they are concatenated together using an ampersand ( & )
string postData = string.Format("authenticity_token={2}&session[username_or_email]={0}&session[password]={1}&commit={3}", username, password, authenticityToken, commit);
ASCIIEncoding enc = new ASCIIEncoding();
// we are encoding the postData to a byte array
b.Navigate("https://twitter.com/sessions", "", enc.GetBytes(postData), "Content-Type: application/x-www-form-urlencoded\r\n");
}
来源:https://stackoverflow.com/questions/23438905/webbrowserdocumentcompletedeventhandler-could-not-be-found