Window Forms

Oct 7, 2013 at 5:28 AM
Hi :

I want to use this library for the using Windows forms, i have creatted a new Project with Windows forms and import the DLL from de compiled and it show many error of dependecy, it can help?? or this library i can not use with Windows Forms.

Regards.
Víctor.
Coordinator
Oct 7, 2013 at 10:35 AM
Hi Victor,

There is currently no reason for Tweetinvi DLL to generate dependency issues with Winforms.
Dependency issues can be generated by targeting a Framework below 4.0 though (which is currently the only requirement).

I can see 2 reasons for a dependency issue :
If you met this 2 requirements you should not have any dependency issue.
I have personally tested the latest version with Winforms and I do not have any dependency issue

If this does not resolve your problem please send me your Error Logs so that I can make further investigations.

Regards,
Linvi
Oct 7, 2013 at 5:59 PM
Hi :

Yes have targeting the framework as 4.0 and 4.5. It show some ambiguos betweeen System.Windows and System.Windows.Forms and the twitterContext is not recognized.

Would you mind sendming an example using the library with Windows Forms??? or the is an example of it???

Regards.
Víctor.
Coordinator
Oct 7, 2013 at 6:29 PM
Hi,

A very simple example Download Winform with Tweetinvi Example :)

Kin Regards,
Linvi
Oct 7, 2013 at 9:38 PM
HI :

I have a oproblem a have download the last binary and import the dll, but something is wrong i want to use the stream filter with the GUI and i have some issue here is my code.


// Track Location
    private static void StreamFilterLocationExample(IToken token)
    {
        //var topLeft = new Coordinates(-122.75, 36.8);
        //var bottomRight = new Coordinates(-121.75, 37.8);

        var topLeft = new Coordinates(-89.673157, 21.056948);
        var bottomRight = new Coordinates(-89.695645, 20.899185);


        var stream = new FilteredStream();
        //stream.AddTrack("tweetinvi");
        stream.AddLocation(topLeft, bottomRight);
        //stream.AddFollow(new TokenUser(token));

        Action<ITweet> tweetReceived = t =>
        {
            Console.WriteLine(t.Text);
        };

        stream.StartStream(token, tweetReceived);
    }


    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        string userKey = "MY-SECURE-KEY";
        string userSecret = "MY-USER-SECRET";
        string consumerKey = "MY-CONSUMER-KEY";
        string consumerSecret = "MY-SECRET-CONSUMER";

        IToken token = new Token(userKey, userSecret, consumerKey, consumerSecret);

        TokenSingleton.Token = token;

// ITokenUser user = new TokenUser(token);
        StreamFilterLocationExample(token);


        //userName.Text = user.Name;
    }
}
}


in the par of addlocation it show me an error, about this show that the visual can no Access to the source code, of course this correct because i using just the binaries the DLL.
And other thing how i can get the properties of StreamFilterLocation
like user_creen , text, to maipulate this propierty for show in the Windows Forms. I have some of this issue.

Regards.
Víctor.
Coordinator
Oct 7, 2013 at 9:40 PM
Hi, Have you been able to download my example and making it work properly?
Oct 7, 2013 at 10:38 PM
Hi :

Yes the example you post i download and work, right now and trying to get estar working with the streamfilter
for show the tweets in the windows forms.

Regards-
Víctor.
Coordinator
Oct 7, 2013 at 10:49 PM
Edited Jan 16, 2014 at 9:42 AM
Attached a solution using a FilteredStream (download).
Marked as answer by linvi on 10/8/2013 at 8:52 AM
Oct 7, 2013 at 11:57 PM
Hello :

Man you are awesome as your library. Please let me be you padawan about the .NET, i trying to add the location, for streaming with coordinates.

Regards.
Víctor.
Coordinator
Oct 8, 2013 at 12:08 AM
Well that should be pretty easy now. Just replace .AddTrack into .AddLocation with your coordinates.
Oct 8, 2013 at 12:14 AM
Edited Oct 8, 2013 at 12:21 AM
Hello :

I have addlocation as and replace the filter at show me error, the application stop working according to log this was the output.

I have modificated the functions as this :

//Function modificated :

private void BackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
    {
        IToken token = new Token(userKey, userSecret, consumerKey, consumerSecret);
        nbTweetDetected = 0;

        IFilteredStream stream = new FilteredStream();

        var topLeft = new Coordinates(-89, 21);
        var bottomRight = new Coordinates(-89, 20);

        stream.AddLocation(topLeft,bottomRight);

        //stream.AddTrack("obama");

        stream.StartStream(token, tweet =>
        {
            backgroundWorker.ReportProgress(++nbTweetDetected, tweet);
            return !backgroundWorker.CancellationPending;
        });
    }
//Output

The thread 'vshost.LoadReference' (0x2008) has exited with code 0 (0x0).
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\victor\Downloads\WinformExampleWithTweetinvi_bueno\WinformExampleWithTweetinvi\WinformExampleWithTweetinvi\bin\Debug\WinformExampleWithTweetinvi.exe', Symbols loaded.
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\victor\Downloads\WinformExampleWithTweetinvi_bueno\WinformExampleWithTweetinvi\WinformExampleWithTweetinvi\bin\Debug\TwitterToken.dll', Symbols loaded.
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\victor\Downloads\WinformExampleWithTweetinvi_bueno\WinformExampleWithTweetinvi\WinformExampleWithTweetinvi\bin\Debug\oAuthConnection.dll', Symbols loaded.
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\victor\Downloads\WinformExampleWithTweetinvi_bueno\WinformExampleWithTweetinvi\WinformExampleWithTweetinvi\bin\Debug\TweetinCore.dll', Symbols loaded.
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\victor\Downloads\WinformExampleWithTweetinvi_bueno\WinformExampleWithTweetinvi\WinformExampleWithTweetinvi\bin\Debug\Streaminvi.dll', Symbols loaded.
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Users\victor\Downloads\WinformExampleWithTweetinvi_bueno\WinformExampleWithTweetinvi\WinformExampleWithTweetinvi\bin\Debug\Tweetinvi.dll', Symbols loaded.
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Web.Extensions\v4.0_4.0.0.0__31bf3856ad364e35\System.Web.Extensions.dll'
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Runtime.Serialization\v4.0_4.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
POST : https://stream.twitter.com/1.1/statuses/filter.json?&locations=-89%2C20%2C-89%2C21
Header OAuth oauth_consumer_key="XwRcS3l6n7nMwxu4Ncmpsg",oauth_nonce="353819",oauth_signature_method="HMAC-SHA1",oauth_timestamp="1381187472",oauth_token="1693649419-VvP3inLWyBikRc25Yik0y4IZYgEW3yAxXArcrgf",oauth_version="1.0",oauth_signature="lYqJ6Tzqzx8My1%2FayqespyLWoIA%3D"
'WinformExampleWithTweetinvi.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.resources\v4.0_4.0.0.0_es_b77a5c561934e089\System.resources.dll'
A first chance exception of type 'System.Net.WebException' occurred in System.dll
A first chance exception of type 'System.Net.WebException' occurred in Streaminvi.dll
An exception of type 'System.Net.WebException' occurred in Streaminvi.dll but was not handled in user code
Additional information: Error en el servidor remoto: (500) Error interno del servidor.
The thread '<No Name>' (0x245c) has exited with code 0 (0x0).
The thread 'vshost.RunParkingWindow' (0x544) has exited with code 0 (0x0).
The thread '<No Name>' (0x1278) has exited with code 0 (0x0).
The program '[8156] WinformExampleWithTweetinvi.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).
Oct 8, 2013 at 1:10 AM
Edited Oct 8, 2013 at 1:14 AM
Hi :

Good News, i have made it work just reaplece the IFIlteredStream by var and everything Works fine i paste following code which it Works correctly :

private void BackgroundWorkerOnDoWork(object sender, DoWorkEventArgs doWorkEventArgs)
    {
        IToken token = new Token(userKey, userSecret, consumerKey, consumerSecret);
        nbTweetDetected = 0;

        //IFilteredStream stream = new FilteredStream();

        var topLeft = new Coordinates(-89.673157, 21.056948);
        var bottomRight = new Coordinates(-89.695645, 20.899185);


        var stream = new FilteredStream();
        //stream.AddTrack("tweetinvi");
        stream.AddLocation(topLeft, bottomRight);

        //stream.AddTrack("obama");

        stream.StartStream(token, tweet =>
        {
            backgroundWorker.ReportProgress(++nbTweetDetected, tweet);
            return !backgroundWorker.CancellationPending;
        });
    }
Coordinator
Oct 8, 2013 at 2:46 PM
Hi Victor,

I do not think that var changed anything.
A 500 error implies that Twitter was not able to manage your request (overload of the servers or other reasons), not that the code was incorrect.

To manage Exception you can register the StreamStopped event and check if an exception occured. If this is the case you can then just restart your stream.
I hope this helps.

May I mark the response with the project zip as answering this post?

Regards,
Linvi
Oct 8, 2013 at 4:14 PM
Hi :

Ok yes when do the changed for var i was suprised that this works,

Of course you can mark the reponse with project zip.

Regards.
Víctor.
Oct 9, 2013 at 4:14 PM
Edited Oct 9, 2013 at 4:15 PM
Hi :

``` I attached my code working and comment with the part that do not work LINK
Mar 11, 2014 at 11:42 AM
linvi wrote:
Attached a solution using a FilteredStream (download).
Many thanks for providing this.

I have however added a line of code taken from the documentation page (https://tweetinvi.codeplex.com/documentation)

// Using Static Tweet class
var tweet = Tweet.PublishTweet("hello");

and the solution no longer compiles. Has library interface changed?

error given in VS2013 is
Error 1 'Tweetinvi.Tweet' does not contain a definition for 'PublishTweet'

Which method should I be using to send a tweet from this solution?

Many thanks
Coordinator
Mar 11, 2014 at 1:04 PM
Hi,

This code is using an old version of Tweetinvi.
Please download the latest example solution here : https://tweetinvi.codeplex.com/releases/view/119124.

Linvi
Mar 11, 2014 at 1:27 PM
Thanks for your quick response.

Compilation is now OK. However despite ensuring account has "Read, Write and Access direct messages" access permission, no tweets are being sent (by this I mean that a follower of the account sees 0 messages from a web browser on twitter.com, after 15 minutes of waiting)

The code I am using is your most recent link (above) with keys and secrets set (I get the expected account name back from "Who am I" when the button is pressed) and with the last three lines below added to send two tweets every time "who am I" button is pressed

private void button1_Click(object sender, EventArgs e)
    {
        var loggedUser = User.GetLoggedUser();
        userName.Text = loggedUser.Name;


        Tweet.PublishTweet("This is a test of the station tannoy system.");

        var tweet = Tweet.CreateTweet("Hello");
        tweet.Publish();
    }
What am I missing ?

Thanks!
Coordinator
Mar 11, 2014 at 2:24 PM
Hi,

Please verify that you have set your credentials correctly.
The please change Tweet.PublishTweet("This is a test of the station tannoy system."); into :
Tweet.PublishTweet("My tweet : " + Guid.NewGuid());
The Guid.NewGuid() allow you to ensure that you do not retweet the same thing twice in a short amount of time because Twitter does not allow to do this from the API.
Same thing for the "Hello" tweet, add Guid.NewGuid at the end.

If this still does not work, please check that the created tweets are not null. If they are please send the information from the ExceptionHandler :
var exceptionInfos = ExceptionHandler.GetLastException();
Linvi
Mar 11, 2014 at 4:21 PM
Edited Mar 11, 2014 at 4:35 PM
Hi Linvi

thank you for your reply.

I believe my credentials have been set correctly because the Who Am I correctly returns the name of the account
I have added the .NewGuid() call to all tweet strings.
The second case of tweet which is created, is NOT null after it is used, however after each of the two lines (i.e. the var creation line and the .Publish()) the last exception is
  • exceptionInfos {"Operation is not valid due to the current state of the object."} TweetinviCore.Exceptions.ITwitterException {TweetinviLogic.Exceptions.TwitterException}
Any ideas?

Edit: that exception is being set on the PublishTweet and on the var tweet = and on the .Publish
Coordinator
Mar 11, 2014 at 5:20 PM
Can you give me the error status code lease?

Regards,
Linvi
Aug 6, 2014 at 7:06 PM
hi, is there a reason why the function would end straight away when trying to listen ? it works fine on my development machine, but as soon as I put it on a clean install of windows 7 it just doesn't listen, the function ends straight away ??

help!!
Editor
Aug 6, 2014 at 7:09 PM
Just an idea, the error "Operation is not valid due to the current state of the object" can sometimes be received if your system time is incorrect.