What's the deal with the ..cctor() error?

This is the error I’m getting:

NullReferenceException
GameUtils..cctor ()
Rethrow as TypeInitializationException: An exception was thrown by the type initializer for GameUtils

GameUtils is a static class containing game state information and such. In my main menu scene, the StartGame button sets the CurrentGameState property in GameUtils before loading the level, but this error comes up, so the level doesn’t load. However, if I start in the level and quit to the menu, I don’t get this error and the level loads fine.

The MainMenu script uses several public fields from GameUtils, so I don’t see how GameUtils can be null.

Edit: Code included below

    // this is in MainMenu OnGUI()
    if (GUI.Button(new Rect(GameUtils.BUTTON_WIDTH / 2, 
        Screen.height - (4 * GameUtils.BUTTON_HEIGHT),
        GameUtils.BUTTON_WIDTH, GameUtils.BUTTON_HEIGHT), "Match Play"))
    {
        GameUtils.CurrentPlayMode = PlayMode.Match;
        Application.LoadLevel("Playfield");
    }

    // this is the property being accessed in GameUtils
    public static PlayMode CurrentPlayMode { get; set; }

where PlayMode is an enum. I’m using an auto-implemented property; I’ve tried using a private field and a regular property that gets/sets it, but it made no difference.

I found the answer here. I was calling GameObject.Find() in my static class, but the object I was trying to find didn’t exist in the Menu scene, so Find() returned null and crashed the initialization. This is the line that was causing the crash:

public static readonly float COURT_WIDTH = 10 * GameObject.Find("Court").transform.lossyScale.x;

It was tricky to figure this out because when I started from the Playfield scene, everything worked fine since the object (the court) I was searching for was in the scene, so Find() did find it. Yeesh…

I’m late to the party, but adding this in case someone else get the …cctor error

Just to re-iterate, the problem occurs when you define AND initialize a variable (in my case, also public static) that uses a reference that doesn’t exist yet - or hasn’t been initialized yet.

Almost always, unity gives you the line number of the error, but NOT in this case - insidious!