Besides reflection, another of the ways that this (more specifically, a null reference exception on a static variable assigned via initializer) can happen is if you have a static constructor defined elsewhere in your class that for some reason sets the value to null, e.g.:
class Program
{
class A
{
private static readonly object _lock = new object();
public void Validate()
{
lock (_lock) // NullReferenceException here...
{
Console.WriteLine("Not going to make it here...");
}
}
static A()
{
Console.WriteLine(_lock.ToString());
Console.WriteLine("Now you can see that _lock is set...");
_lock = null;
}
}
static void Main(string[] args)
{
var a = new A();
a.Validate();
}
}