This project has moved. For the latest updates, please go here.

Different results for same queries in VB and C#

Feb 4, 2010 at 6:15 PM


I've coded some stuff using LinqToTwitter in C# and then I decided to use LinqToTwitter in a VB web application.

If I do the following query in C#

var users = from user in userData.User
            where user.Type == UserType.Show &&
                user.ScreenName == userData.UserName
            select user;

Nice. It works properly, returning my profile.

But if I do something similar in VB, just like

Dim users = From user In userData.User _
            Where user.Type = UserType.Show _
                AndAlso user.ScreenName = userData.UserName _
            Select user

It returns a profile that isn't mine, in this case, a one of my followers' profile.

In some other queries I've done, to return friends, reTweets and direct messages, the results are still wrong (it returns eg the last tweets in Twitter without any filter).

But in C# all of them works nice.

What could explain that?

Feb 12, 2010 at 12:19 AM

I've been a little backlogged lately, but will take a look soon.


Feb 12, 2010 at 6:04 PM

Thanks Joe. If necessary, I can post my code when you ask for.

Feb 15, 2010 at 3:14 PM

I ran the code above and it worked correctly.  What version of LINQ to Twitter are you using?  There was a problem with VB queries in earlier versions of LINQ to Twitter because VB generates a different expression tree than C#, but I implemented a fix for that a few months ago.  If you're using an older version, try getting the latest.  I just checked in code samples that include your example above.  If you're still seeing problems, let me know (post more example queries) and I'll help find out what is wrong.


Feb 17, 2010 at 2:49 PM

Joe, I think I´ve found the problem.

Using the debug DLL, the queries don't work correctly. Using the release DLL, it works. In the version 2.0.7 debug and release DLLs are very different, eg they have different constructors for TwitterContext. The debug version has TwitterContext constructors that doesn't implementate OAuth authorization. Rebuilding the debug version I solved the problem (but I needed to change my code to implementate the OAuth authorization). Nothing complicated, just building debug version all became the same.

Thanks for helping.