Why would finding a type’s initializer throw a NullReferenceException?

This has got me stumped. I was trying to optimize some tests for Noda Time, where we have some type initializer checking. I thought I’d find out whether a type has a type initializer (static constructor or static variables with initializers) before loading everything into a new AppDomain. To my surprise, a small test of … Read more

What is a NullReferenceException, and how do I fix it?

This question’s answers are a community effort. Edit existing answers to improve this post. It is not currently accepting new answers or interactions. I have some code and when it executes, it throws a NullReferenceException, saying: Object reference not set to an instance of an object. What does this mean, and what can I do … Read more