Hiya,
I am using TweetInvi as part of a service that monitors a Twitter account, and replies according to various events (mentions, new followers). I've had a few cases where the entire sevice dies due to TweetInvi throwing a NullReference exception at random. Below are two example errors that I've seen in the event viewer:
```
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Func`2<System.String,Boolean>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Action`1<System.String>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.UserStream.StartStream()
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Func`2<System.String,Boolean>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Action`1<System.String>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.FilteredStream.StartStreamMatchingAnyCondition()
```
These exceptions get thrown "mid-flight", with the service having already been running for a few hours/days. The API is initialised like so:
```
TwitterCredentials.Credentials =
TwitterCredentials.CreateCredentials(configuration.Authentication.AccessToken,
configuration.Authentication.AccessTokenSecret, configuration.Authentication.ConsumerKey,
configuration.Authentication.ConsumerSecret);
currentUser = User.GetLoggedUser();
userStream = Stream.CreateUserStream();
userStream.TweetCreatedByAnyone += UserStreamOnTweetCreatedByAnyone;
userStream.MessageReceived += UserStreamOnMessageReceived;
userStream.DisconnectMessageReceived += UserStreamOnDisconnectMessageReceived;
userStream.UnmanagedEventReceived += UserStreamOnUnmanagedEventReceived;
userStream.FollowedByUser += UserStreamOnFollowedByUser;
ThreadPool.QueueUserWorkItem(state => userStream.StartStream());
filteredStream = Stream.CreateFilteredStream();
foreach (TrackElement track in configuration.Tracking)
filteredStream.AddTrack(track.Track);
filteredStream.MatchingTweetReceived += FilteredStreamOnMatchingTweetReceived;
ThreadPool.QueueUserWorkItem(state => filteredStream.StartStreamMatchingAnyCondition());
```
I am using version 0.9.0.0 of the TweetInvi library.
Is this a known issue, or am I doing something wrong?
I am using TweetInvi as part of a service that monitors a Twitter account, and replies according to various events (mentions, new followers). I've had a few cases where the entire sevice dies due to TweetInvi throwing a NullReference exception at random. Below are two example errors that I've seen in the event viewer:
```
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Func`2<System.String,Boolean>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Action`1<System.String>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.UserStream.StartStream()
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Func`2<System.String,Boolean>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.Helpers.StreamResultGenerator.StartStream(System.Action`1<System.String>, System.Func`1<System.Net.HttpWebRequest>)
at Streaminvi.FilteredStream.StartStreamMatchingAnyCondition()
```
These exceptions get thrown "mid-flight", with the service having already been running for a few hours/days. The API is initialised like so:
```
TwitterCredentials.Credentials =
TwitterCredentials.CreateCredentials(configuration.Authentication.AccessToken,
configuration.Authentication.AccessTokenSecret, configuration.Authentication.ConsumerKey,
configuration.Authentication.ConsumerSecret);
currentUser = User.GetLoggedUser();
userStream = Stream.CreateUserStream();
userStream.TweetCreatedByAnyone += UserStreamOnTweetCreatedByAnyone;
userStream.MessageReceived += UserStreamOnMessageReceived;
userStream.DisconnectMessageReceived += UserStreamOnDisconnectMessageReceived;
userStream.UnmanagedEventReceived += UserStreamOnUnmanagedEventReceived;
userStream.FollowedByUser += UserStreamOnFollowedByUser;
ThreadPool.QueueUserWorkItem(state => userStream.StartStream());
filteredStream = Stream.CreateFilteredStream();
foreach (TrackElement track in configuration.Tracking)
filteredStream.AddTrack(track.Track);
filteredStream.MatchingTweetReceived += FilteredStreamOnMatchingTweetReceived;
ThreadPool.QueueUserWorkItem(state => filteredStream.StartStreamMatchingAnyCondition());
```
I am using version 0.9.0.0 of the TweetInvi library.
Is this a known issue, or am I doing something wrong?