2

I have the following code which is intended to fetch a list of all the user of an organisation.

public static IEnumerable<Member> ListTrelloUsers()
    {
        var serializer = new ManateeSerializer();
        TrelloConfiguration.Serializer = serializer;
        TrelloConfiguration.Deserializer = serializer;
        TrelloConfiguration.JsonFactory = new ManateeFactory();
        TrelloConfiguration.RestClientProvider = new RestSharpClientProvider();
        TrelloAuthorization.Default.AppKey = ApplicationKey;
        TrelloAuthorization.Default.UserToken = GrandToken;

        var myOrganization = Member.Me.Organizations.FirstOrDefault().Id; //Exception thrown here.
        var orgToAddTo = new Organization(myOrganization);

        return orgToAddTo.Members.AsEnumerable();
    }

But I'm getting a

System.MissingMethodException

thrown on

RestSharp.IRestRequest RestSharp.RestRequest.AddFile(System.String, Byte[], System.String)

So why is this exception thrown and what should the correctly working code look like?

Clarifications

I will also accept working C#/ASP.Net MVC code that isn't based on Manatee.Trello as an answer. (Including pure API-calls.)

I have tried using the Organisation ID directly as

var orgToAddTo = new Organization(OrganisationId);

but that just caused the same exception to be thrown later when I make a call to the method's returned object (e.g. using Count()).

UPDATE: I tried setting the build to Release instead of Debug and now the (same) exception is instead thrown at

TrelloConfiguration.RestClientProvider = new RestSharpClientProvider();
PChristianFrost
  • 120
  • 2
  • 13

2 Answers2

1

Apperently, the class with missing method is located in an assembly, which differ from the one, which you used while compiling the project. Double check and make sure both at compiling and at execution you use the same assembly with the aforementioned class. That is my best clue based on the info you've provided.

  • basically, check project references and make sure, you use correct ones for the class-holding assembly.
Anatolyevich
  • 671
  • 5
  • 14
  • Do you mean that I should check so that the references used have the same version number as the NuGet-packages installed? – PChristianFrost Feb 26 '16 at 10:05
  • ... as well as to make sure, the same actual build is used in both cases. As the same build version may have different implementations (even though is totally inacceptable). So, the best would be to make sure that in execution folder you have the same "phisical" file of assembly as you used for reference while builded your project. – Anatolyevich Feb 26 '16 at 10:23
  • There is only one build since it's a series of NuGet-pakages that I have only ever installed one version/build of. – PChristianFrost Feb 26 '16 at 12:13
  • Well, as for me, it sounds too weird you have such an exception. My best advise would be to use VS debugger and dig into the line exception is thrown at.. (Use F11 at that line). VS 2015 have very nice feature of digging into assemblies, so there is a great chance you'll find the line and the reason which makes the Exception thrown.. Can't figure out any better idea. – Anatolyevich Feb 26 '16 at 12:56
  • What using Step Into/F11 does to me is that I get an error message about me not having the source code to Manatee.Trello :/ – PChristianFrost Feb 26 '16 at 13:30
  • Seems like you have not the latest VS. Then, I have no Idea, man.. Already told my best clue. – Anatolyevich Feb 26 '16 at 15:50
  • 2015 community Update 1 and I'm getting the feeling that you haven't really used Manatee.Trello – PChristianFrost Feb 29 '16 at 08:15
  • Your 2nd sentence doesn't make any sense. See @gregsdennis answer regarding solving the problem. – PChristianFrost Mar 01 '16 at 08:46
1

This is an issue with RestSharp that I reported quite some time ago, though they deny that it's a problem. If you're using .Net 4.5+, you can try the Manatee.Trello.WebApi package instead of Manatee.Trello.RestSharp.

TrelloConfiguration.RestProvider = new WebApiClientProvider();

Here's my Trello card for tracking the issue. This and this are the RestSharp issues I created.

I have been able to recreate this as well, but have received no help from them to resolve it.

gregsdennis
  • 7,218
  • 3
  • 38
  • 71