Welcome to the Treehouse Community
Looking to learn something new?
System.NullReferenceException, filename unknown (Tower Defense project)
Hello all — I'm getting the following error when running my code:
Unhandled exception reads: System.NullReferenceException: Object reference not set to an instance of an object at TreehouseDefence.Game.Main () <0x4087fd50 + 0x0041b> in <filename unknown>:0
It compiles just fine. Here's a snapshot:
I guess I have two questions:
1) Why am I not getting details on where this exception is stemming from? Even if I run the compiler using -debug I don't get any extra details. All I can work out is that it's coming from somewhere within the try ... catch block in my Main() method.
2) What part did I mess up?? Hah.
Steven Parker221,296 Points
I was able to replicate your message by running "Game.exe", but I noticed that it had been built before the last edit to "Game.cs".
So I rebuilt the project and when I run that, I get no error. So it seems you'd already fixed the issue in the source but just had not rebuilt yet.