I am working on a twitter project that lets user to auto-tweet to the mentioned tweets using C#. I am using TweetSharp with C#. The problem is, when I try to refresh the form_load that shows the mentioned tweets using timer, I get NullReferenceException was unhandled error. I tried change the time interval from 20seconds to 40seconds just in case if the problem is with the time interval, but the problem still existed, hence I don't think the problem is with the time interval. If anyone can help me with this problem I will really appreciate.
Below is when to refresh the Form1_Load:
var timer = new Timer();
timer.Tick += new EventHandler(Form1_Load);
timer.Interval = 20000; //40 seconds
timer.Start();
This is where I get the error:
private void Form1_Load(object sender, EventArgs e) // form load bolumu
{
listView1.Items.Clear();
tweetid.Items.Clear();
userid.Items.Clear();
username.Items.Clear();
var received= service.ListTweetsMentioningMe(new ListTweetsMentioningMeOptions { Count = 15 });
**foreach (var tweet in received)** --> This is where I get the error NullException
{
ListViewItem lvi = new ListViewItem(tweet.Text);
listView1.Items.Add(lvi);
lvi.SubItems.Add("@" + tweet.User.ScreenName.ToString());
lvi.SubItems.Add(tweet.CreatedDate.ToString());
userid.Items.Add(tweet.User.Id.ToString());
tweetid.Items.Add(tweet.Id.ToString());
}
Thank you again.