UpdateStatus method gone from TwitterContext

May 24, 2013 at 11:02 PM
I recently updated LinqToTwitter to version 2.1.04, and now my code using UpdateStatus(tweet) is broken. Looking at the TwitterContext class, it seems the method is gone, but this method is still recommended by the documentation as the way to tweet. What am I missing?
Coordinator
May 24, 2013 at 11:06 PM
Hi,

The latest version is 2.1.05 and it fixes a known problem with receiving 401's, which might be what you're seeing.

@JoeMayo
May 24, 2013 at 11:20 PM
Edited May 24, 2013 at 11:20 PM
Thanks for your reply. I'm not receiving a 401; my code won't compile. Here's the error I get: 'LinqToTwitter.TwitterContext' does not contain a definition for 'UpdateStatus' and no extension method 'UpdateStatus' accepting a first argument of type 'LinqToTwitter.TwitterContext' could be found (are you missing a using directive or an assembly reference?) I don't know what using directive or assembly reference I could be missing considering that the code worked when I was on a much older version of LinqToTwitter.

The method UpdateStatus literally does not appear in the TwitterContext class, neither in my solution nor in your documentation here on CodePlex. However, in versions from November 2011, there were many virtual methods named UpdateStatus.

I have updated to 2.1.05 anyway, and it didn't solve the problem.
Coordinator
May 24, 2013 at 11:32 PM
It's an extension method. A few questions:
  1. Are you using VB? I've seen posts by some people using VB who were seeing similar errors.
  2. What .NET version are you using?
  3. Does the sample code in the downloadable source code, in the LinqToTwitterDemo project work for you?
  4. What technology are you using? i.e. WPF, ASP.NET, etc.
@JoeMayo
May 28, 2013 at 6:40 PM
  1. No, I'm using C#.
  2. .NET version 4.0.30319 SP1Rel
  3. Yes. The UpdateStatus method doesn't yield an Intellisense error, and I can view the method in StatusExtensions.cs. However, I do get a notice to install the latest Silverlight Developer runtime before opening LinqToTwitterAg. I tried to do this and got an error message saying that Silverlight was already installed. So I ran Windows Update, and noticed a Silverlight update was part of it. Then I restarted my computer and verified I was on the latest version, but I got the same error.

    Because StatusExtensions.cs is inside LinqToTwitterAg, I think this might be relevant to my problem. To clarify: I can navigate to StatusExtensions.cs by rightclick>Go To Definition on one of its methods, but inside Solution Explorer, the LinqToTwitterAg project (and the LinqToTwitterRT project) show as "unavailable".
  4. ASP.NET Web Forms.
In my own project, I'm using LinqToTwitter through a .dll I downloaded through NuGet, so I can't tell what components are loading properly and which aren't. I suspect StatusExtensions.cs is not actually being loaded/recognized. Does this sound accurate, and do you have advice on how to fix it? Thanks so much for your help so far.
Coordinator
May 28, 2013 at 7:13 PM
First, let's make sure you're using the proper DLL. If you have a Silverlight project reference, then the proper DLL is named LinqToTwitterAg.dll. If you have a Web Forms project reference, the proper DLL should be named LinqToTwitter.dll.

In #3, you're discussing Silverlight, but in #4 you're discussing Web Forms, so I'm mentioning both technologies just in case.

In the downloadable source code, there are a couple samples: the Web Forms demo is named LinqToTwitterWebFormsDemo and the Silverlight demo is in both the LinqToTwitterSilverlightDemo and LinqToTwitterSilverlightDemo.Web folders. Neither of these demos are included in the solution, but they can be added.

It might help to get the demos running and try to find the delta between them and your project.

Also, I created brand new .NET 4.0 projects in VS 2012 to see if something might look funny and pulled in LINQ to Twitter via NuGet, but everything seems to compile and find extension methods okay. You might also try this, creating a brand new test project and then using NuGet to reference LINQ to Twitter. If it works, this might provide another delta to compare your project with.

@JoeMayo
May 28, 2013 at 8:16 PM
Edited May 28, 2013 at 8:17 PM
I created a new solution, got LinqToTwitter through NuGet, and encountered the same problem with UpdateStatus. Both the project I posted about and the new one are Web Forms (not Silverlight), and I confirmed that the DLL is named LinqToTwitter.dll. For what it's worth, I'm using VS 2010, not 2012.
May 29, 2013 at 7:28 PM
Just grasping at straws, I downloaded the zip file of all the DLLs and manually tried the one NuGet selected (LinqToTwitter.dll in folder "net40") in my almost-empty test project. I also tried (separately, of course) LinqToTwitter.dll in folder "net45", LinqToTwitterCP.dll in "net40-client", and LinqToTwitterAg.dll in "sl40". None of these caused my project to recognize UpdateStatus.

Adding the DLL should be all I need to do, right? The extension methods are in the DLL with everything else, and there's nothing special I need to do (like a setting I need to flip) to make Visual Studio look for them?
Coordinator
May 29, 2013 at 9:40 PM
Right, all you have to do is add LinqToTwitter.dll and things should work fine. I just opened VS 2010, created a new Web application and modified Default.aspx.cs like this:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using LinqToTwitter;

namespace WebApplication2
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            var ctx = new TwitterContext();
            ctx.UpdateStatus("Text");
            StatusExtensions.UpdateStatus(ctx, "Text");
        }
    }
}
Are you able to do "StatusExtensions.UpdateStatus(ctx, "Text");" ?

Joe
May 30, 2013 at 3:23 PM
Thanks so much for your help. As it turns out, all I needed to do was add using LinqToTwitter; at the top of the class (something that occurred to me to try when I saw it in your latest snippet). Previously I was just explicitly referencing LinqToTwitter whenever I used it and it worked, but I guess in the new version that interfered with finding the extension method. Sorry to have made you run in circles, but I'm very grateful you put in so much effort advising me.