TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Samuel Amantea Collins
NA
10
0
Internet Explorer object "Object reference not set to an instance of an object."
Jul 7 2010 2:45 PM
I've been trying to write an aplication to automatically log me in to facebook, pointless i know but it's a step to a greater goal. Anyway, here's the sticking point:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using SHDocVw;
namespace SpamThis
{
public partial class Form1 : Form
{
string UserNames = "";
string Passwords = "";
InternetExplorer Browser;
HtmlDocument Doc;
public Form1()
{
InitializeComponent();
}
private void UserName_TextChanged(object sender, EventArgs e)
{
UserNames = UserName.Text;
}
private void Password_TextChanged(object sender, EventArgs e)
{
Passwords = Password.Text;
}
private void Login_Click(object sender, EventArgs e)
{
Browser = new InternetExplorer();
object o = null;
Browser.Visible = true;
Browser.AddressBar = false;
Browser.Navigate("http://www.facebook.com/", ref o, ref o, ref o, ref o);
while (Browser.Busy)
{
}
Doc.GetElementById("reg_email__").SetAttribute("reg_email__", UserNames);
}
}
}
The line highlighted in red gives me this error: "Object reference not set to an instance of an object."
And then when i try adding this line just above it:
Doc = (HtmlDocument)Browser.Document;
it says that i can not convert to this type. How do i retrieve and edit the instance of IE's html document?
Is this the correct way to implement this code? Can anyone help?
Much appreciated
Reply
Answers (
3
)
crystal report printing in roll paper using ASP.net (VB)
how to embed images into my asp page..