Cannot use static class when placing a static constructor : <p>I have the following static class:</p>

<pre><code>public static class UnitTestDefinitions
{
    public static int Foo = 4;

    /// &lt;summary&gt;
    ///     static constructor
    /// &lt;/summary&gt;
    static UnitTestDefinitions()
    {
        InitAccounts();
    }

     private static void InitAccounts()
     {
         // some code
     }

     // more code
 }
</code></pre>

<p>I have a NUnit test that fails to run because I cannot access <code>Foo</code> :</p>

<p><a href="https://i.stack.imgur.com/AuHOj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AuHOj.png" alt="enter image description here"></a></p>

<p>The actual exception that I get is:</p>

<blockquote>
  <p>System.TypeInitializationException was unhandled by user code<br>
  HResult=-2146233036   Message=The type initializer for
  'Ublux.Communications.PrimaryService.UnitTestDefinitions' threw an
  exception.   Source=Ublux.Communications.CoreService<br>
  TypeName=Ublux.Communications.PrimaryService.UnitTestDefinitions<br>
  StackTrace:
         at Ublux.Communications.CoreService.UnitTests.TestCloudServicesCore.TestAuthentication()
  in C:\GIT\Ublux\Ublux Communications Core
  Service\Ublux.Communications.CoreService\Ublux.Communications.CoreService\UnitTests\TestCloudServices_Core.cs:line
  146   InnerException: 
         HResult=-2146233040
         Message=Exception of type 'System.Threading.ThreadAbortException' was thrown.</p>
</blockquote>

<p><strong>I been using c# for a while so to me it is obvious that the problem has to be in the static constructor, In other words there has to be a problem with the method <code>InitAccounts()</code>.</strong>  </p>

<hr>

<p>Because of that I REMOVED the static constructor on the static class UnitTestDefinitions and call the <code>InitAccounts()</code> method manually as:</p>

<p><a href="https://i.stack.imgur.com/d5uQ8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d5uQ8.png" alt="enter image description here"></a></p>

<h2>When I do that I get no exception and everything works great why?</h2>
