3

I am confused ( that is easy enough!). I have a small snippet of code that I have taken a screenshot of.

The NRE arises after a failed test for a file path. Nothing there is null. The SceneryAreas object is initialized just before this test. However (and my screenshot did not pick it up) it seems that in the line SceneryAreas.Clear(); that SceneryAreas is null. Is it possible that the error is being shown on the wrong line and more to the point how could the instantiated object become null at this point?

Screenshot of VS 2010 IDE

Many thanks for any suggestions - I have never seen this before.

6
  • Use "View Detail" - check the Stack Trace - where did the exception actually originate from? Commented Jun 20, 2012 at 14:51
  • It is clear by the exception that FilePath is what is null. Commented Jun 20, 2012 at 14:52
  • @Ramhound, that will not raise the NRE Commented Jun 20, 2012 at 14:54
  • Folks - you are right. For some reason VS2010 is not compiling the library containing this code with the latest lines. Hence the line for instantiating SceneryAreas is not actually there Commented Jun 20, 2012 at 14:58
  • 1
    Check your build configuration and make sure that the library is set to build. Also, if you're referencing this libary from an executable project, check that you created a project reference and not just a reference to the compiled DLL. A project reference correctly sets up dependencies in VS so that changes to the source code trigger a rebuild. Commented Jun 20, 2012 at 15:05

3 Answers 3

5

Your source code or symbols file is not in synch with your compiled code, hence the debugger is highlighting the wrong line.

If you recompile and re-run it should break on the line in your source which is causing the problem.

Sign up to request clarification or add additional context in comments.

Comments

1

It is possible that the error's shown against the wrong line. Try rebuilding your project to make sure that the source files are in sync with the code being debugged. Also, check the stack trace under View Detail... to see exactly where the exception is being thrown.

Comments

1

As others said, the file does not correspond with the one used to build the assembly. The easiest way to check this is trying to set a breakpoint on the file, you will see a red circle saying that the file is different from the built one.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.