I don't think I have seen this type of error in C# before and I have been using C# for years, but then again, I am new to Aysnc and Task in C# so maybe it's related. I have a method declared as follows:
private async Task MyMethod(...)
I call this method as follows:
await MyMethod(...)
Inside MyMethod(...), I am making some calls to other synchronous methods, but I believe that is allowed in C#, right? In any case, when debugging inside MyMethod(...) with Visual Studio, I can also see my synchronous methods completing normally.
So everything seems to be going well in MyMethod(...), until the final closing curly bracket is hit, where MyMethod(...) should be exiting:
When the final curly bracket is hit to exit MyMethod(...), I get a System.NullReferenceException. Does anybody know what is going on and why I am getting a System.NullReferenceException?
Edit: If I make MyMethod(...) a normal synchronous method (ie. I remove async Task, and I don't call await on it), then it can complete normally with no exceptions and no errors.