1

I have taken over a Xamarin.Forms (C#) application from an external source for fixing.

Problem is, that the application does sometimes fail with a runtime error:

System.NullReferenceException: Object reference not set to an instance of an object

The message appears in the output console and in a separate message window in Visual Studio. Unfortunately neither gives any more information about the failed object, a source code line number or a classname, there is just the bare message. Furthermore the "Call Stack" window in Visual Studio is always empty --> I have no easy way to find out where the failure occurs in foreign source code, because virtually no documentation of the program flow exists.

Full source code is available, and I have re-built the application with "Debug" configuration.

Right now the only option I can think of is to scatter breakpoints and Debug.Writelines all over the source code to get an idea where the problem occurs.

Is this really my only option, or did I miss some setting somewhere, so I can retrieve more info, so I can somehow go straight to the code where the failure occurs?

Thx!

Nimral
  • 657
  • 8
  • 25
  • Possible duplicate of [What is a NullReferenceException, and how do I fix it?](https://stackoverflow.com/questions/4660142/what-is-a-nullreferenceexception-and-how-do-i-fix-it) – Ken White Feb 14 '18 at 17:45
  • 1
    Interesting article, no doubt. Nevertheless no duplicate. I know what the cause of a NullReferenceException is. My question is targetet at efficient ways to find where it happened, in unknown source code. Stepping unknown sourcecode is a huge time guzzler, specially if it is no linear code "spaghetti" but event driven code chunks scattered all over x source files. That's why nowadays most debugging systems are able to provide a stack trace, an object name or a line number. Can't quite believe that Visual Studio / Xamarin debuger lacks this very basic functionality. – Nimral Feb 14 '18 at 18:54
  • @Nimral, How about using the Exception settings windows? – Fletcher Feb 16 '18 at 09:25

0 Answers0