Why am I getting, “Object reference not set to an instance of an object.” but no line of code is implicated?

This was an incredibly strange issue, but since there it has been solved, it might as well get an answer.

I think it’s a bug in the .suo files, as my VS was behaving oddly lately, my programs suddenly started crashing, not building and saying the Office references were not valid.

One fix I tried was cleaning and re-building the solution, which worked about 1/4 in times, the other times I had to physically remove and add the references again, and then rebuild the whole solution.

After getting fed up of doing that for a week or so, I just created a backup elsewhere on our work server, deleting the .suo files in the new folder, then opening and building the whole solution.

It fixed it. Not sure why, or what went wrong, but now and then strange things happen in the .suo files and references.

Leave a Comment