I have a static class with a static field that is initialized in place:
private static SomeType _instance = new SomeType();
This code is a part of a portable class library that is used on multiple platforms. Everything works fine on desktop platforms, but when compiled for Windows Phone 8 the _instance is null. But if I move the initialization to a default static constructor, the _instance is initialized properly.
I tried to search for an explanation of this behavior but haven't found anything that would explain it.
UPDATE. I spent some time trying to create a repeatable sequence of steps to reproduce the error, but at some point error no longer occurred even when I switched back to the original code. I came to conclusion that this was a false alarm and the problem was apparently caused by something else. I don't feel comfortable to leave it without explanation, but so far I have no grounds to believe that this has to do with static field initialization.