Can beforefieldinit have any effect other than time of static constructor execution?
<p>I have a class with a static constructor:</p>

<pre><code>private static readonly Dictionary&lt;string, User&gt; UsersByName;
private static readonly Dictionary&lt;string, User&gt; UsersByEmail;

static MyClass() {
     List&lt;User&gt; users = GetUsers();
     UsersByName = users.ToDictionary(user =&gt; user.Name);
     UsersByEmail = users.ToDictionary(user =&gt; user.Email);
}

private static List&lt;User&gt; GetUsers() { /* Make a WCF service call */ }
</code></pre>

<p>My problem was that whenever I made that WCF call, <em>all of the worker threads</em> in this web application died. After a lot of head scratching and binary chopping I found the root cause - it happened when we added <code>UsersByEmail</code>, and moved the code into a static constructor. Changing the code to the following fixed everything.</p>

<pre><code>private static readonly List&lt;User&gt; AllUsers = GetUsers();
private static readonly Dictionary&lt;string, User&gt; UsersByName = AllUsers.ToDictionary(user =&gt; user.Name);
private static readonly Dictionary&lt;string, User&gt; UsersByEmail = AllUsers.ToDictionary(user =&gt; user.Email);

private static List&lt;User&gt; GetUsers() { /* Make a WCF service call */ }
</code></pre>

<p>Leaving aside the bad design of calling WCF from a static constructor (which break the app until it's restarted if the service happens to be down), because that is temporary code - I'm trying to find out why the change fix this problem. I ran it in the debugger many times, with the only difference being me adding or removing an empty static constructor; the call stack is always the same meaning the web service is called at the same time, so I don't see how being called from a class without a static constructor could make any difference.</p>
