0

I'm trying mailup for the first time and I just installed the nuget package (1.1.7) from https://www.nuget.org/packages/MailUp.Sdk/

And then to give it a try I've tried the first example in their documentation in here

 public static void GetUserInfo(string username, string password)
    {
        // 1) Setup the MailUp Client:
        MailUpClient client = new MailUpClient();

        // 2) Invoke the web method:
        List<UserInfoDTO> result = null;
        try
        {
            result = client.ListUserInfo(username, password);
        }
        catch (Exception ex)
        {
            Console.WriteLine("Cannot perform the operation due to " + ex.Message);
            return;
        }

        // 4) Print results:
        if (result != null)
            Console.WriteLine("Retrieved users total:" + result.Count);
        else
            Console.WriteLine("An error occurred while retrieving users.");
    }

When I run the code simply it throws null reference exception on the MailUpClient client = new MailUpClient(); line. Any ideas?

update 1

Please find the exception details below:

System.NullReferenceException HResult=0x80004003 Message=Object reference not set to an instance of an object. Source=MailUp.Sdk StackTrace: at MailUp.Sdk.Base.MailUpClient..ctor() at mailupTest.Program.GetUserInfo(String username, String password) in C:\Users...source\repos\mailupTest\mailupTest\Program.cs:line 20 at mailupTest.Program.Main(String[] args) in C:\Users...\source\repos\mailupTest\mailupTest\Program.cs:line 14

Ashkan S
  • 10,464
  • 6
  • 51
  • 80
  • how about try catch around that line and posting a full exception stack here? – matcheek Jun 21 '18 at 07:25
  • 1
    It sounds like the error is in the library's code and there's not much we can do to help you fix your code. If the source is available then you should try track down the error and report it to the authors. Otherwise, what are we going to do? Would you like us to handle your support request for you? – Enigmativity Jun 21 '18 at 07:29
  • @Enigmativity I was wondering if anyone have experienced the same thing. I wasn't expecting you to support me. and also I was trying to help the next one facing the same error as nothing shows up on google and this library is 2 years old – Ashkan S Jun 21 '18 at 07:31
  • @Enigmativity It is not a duplicate of null reference exception! It is not even relevant to it. – Ashkan S Jun 21 '18 at 07:33
  • @AshkanSirous - Yes, I've experienced the same thing, but with different libraries. You get the source and you debug it. You need to at least demonstrate your effort in solving the problem before asking us to. – Enigmativity Jun 21 '18 at 07:33
  • @Ashkan it is relevant if you have the source code. If you don't have the source code, it's a support issue for the person or company that distributes the closed source library. – ProgrammingLlama Jun 21 '18 at 07:34
  • 1
    @AshkanSirous - Yes, it is exactly relevant. You get the source and you track down the NRE. It is 100% the same situation. What makes you think it is not? – Enigmativity Jun 21 '18 at 07:34
  • If you can, debug the source code, fix the bug, send them a pull request. – ProgrammingLlama Jun 21 '18 at 07:35
  • @Enigmativity if I've had the source code, I wouldn't ask it here :) – Ashkan S Jun 21 '18 at 07:35
  • @john I will if I can have my hands on their dirty, faulty code! :D null reference exception on creating a class is just funny – Ashkan S Jun 21 '18 at 07:38
  • @AshkanSirous - Since you don't have the source code then you shouldn't be asking it here. Ask the authors. – Enigmativity Jun 21 '18 at 07:38
  • I imagine they might be doing something silly like looking at a static class they expect you to populate before you create a class, but that's a pure guess without having looked at the library. It could just be a dumb bug. – ProgrammingLlama Jun 21 '18 at 07:38
  • I've retracted my previous link, because I realised MailUp's "report a bug" page just goes to Atlassian's JIRA, not MailUp's. [Correct link](https://mailup.atlassian.net/secure/MyJiraHome.jspa) – ProgrammingLlama Jun 21 '18 at 07:40
  • @john it says that I don't have access to their confluence. How do you have access? :D – Ashkan S Jun 21 '18 at 07:43
  • 1
    @AshkanSirous - I've just NuGetted the library into LINQPad and then invoked ILSpy for the query and can see all of the source code - they haven't obfuscated. You should be able to investigate that way. – Enigmativity Jun 21 '18 at 07:44
  • @AshkanSirous - I'm also fairly certain that I know what the problem is. You should be able to solve it in about 30 seconds after spying on the IL. – Enigmativity Jun 21 '18 at 07:46
  • Do you have `MailUpClientID` and `MailUpClientSecret` defined in your web.config or app.config? – ProgrammingLlama Jun 21 '18 at 07:48
  • @Enigmativity I'm trying to install dotpeek to read their code. Thanks for the help – Ashkan S Jun 21 '18 at 07:57
  • @john Thanks for the help. That was it! Purely written code that doesn't even handle something like this. I'm gonna open their source as Enigmativity suggested and find my way through. Thank you very much for helping – Ashkan S Jun 21 '18 at 07:59
  • 1
    @Ashkan Glad we could help. It's a pretty poor show that they don't validate input and throw an appropriate exception :-( – ProgrammingLlama Jun 21 '18 at 07:59
  • 1
    @john - It appears that the default constructor isn't guarding against missing configuration settings. Yes, pretty poor. – Enigmativity Jun 21 '18 at 08:22

0 Answers0