title: Type initializer exception - C#
body: <pre><code>namespace X{  public static class URLs
  {
      public static TabController tabIdLookUp = new TabController();
      public static string DASHBOARD_AUDIT_PAGE = tabIdLookUp.GetTabByName("View My Safety", 2).TabID.ToString();
      public static string URL_GENERATE_WITH_MID(String TabName, int PortalId){        {
          return tabIdLookUp.GetTabByName(TabName, PortalId).TabID.ToString();
      }
  }}
  </code></pre>
  
  <p>... 
  in my user control i do this:</p>
  
  <pre><code>Response.Redirect("/" + X.URLs.URL_GENERATE_WITH_MID("test", 1)); // this causes the error
  </code></pre>
  
  <p>the error is: The type initializer for 'X.URLs' threw an exception. ---> System.NullReferenceException: Object reference not set to an instance of an object. at X.URLs..cctor() </p>
  
  <p>can't debug because it works on my local box, but throws that error on the server.</p>
  
  <p>any ideas?</p>
  
  <p>P.S. the problem ended up being a trivial NUllReferenceException - GetTabByName() was returing NULL </p>