title: C# Error "The type initializer for ... threw an exception
body: <p>This error occurs only in some computers. By reading the stack information, there is some problem when I call to this static method ("FormatQuery") in a static class:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Data;
  using System.Diagnostics;
  using System.IO;
  using System.Text;
  using System.Windows.Forms;
  using DevExpress.XtraEditors;
  using FlexCel.Report;
  using FlexCel.XlsAdapter;
  using ComboBox=System.Windows.Forms.ComboBox;
  
  namespace XSoftArt.A
  {
      static class RHelper
      {
          private static string FormatQuery(string FieldName, int Count,
              CheckedListBox chekedListBox)
          {
              string ID = string.Empty;
              int n = Count;
  
              foreach (DataRowView item in chekedListBox.CheckedItems)
              {
                  ID = ID + item["" + FieldName + ""];
                  if (n &gt; 1)
                  {
                      ID = ID + " , ";
                      n--;
                  }
              }
              return ID;
          }
  
          public static string FormatQuery(CheckedListBox chekedListBox)
          {
              return FormatQuery(chekedListBox.ValueMember,
                  chekedListBox.CheckedItems.Count, chekedListBox);
          }
      }
  </code></pre>
  
  <p>So, what's the problem? How do I solve it? Is there something wrong with the project configuration or debbuging mode or what?</p>
  
  <p>Error information:</p>
  
  <pre><code>   at XSoftArt.EVS.ReportHelper.FormatQuery(CheckedListBox chekedListBox)
     at XSoftArt.EVS.NewEmailSelectClient.LoadList_v2(String search, TextBox txtbox)
     at XSoftArt.EVS.NewEmailSelectClient.LoadContacts()
     at XSoftArt.EVS.NewEmailSelectClient.button7_Click(Object sender, EventArgs e)
     at System.Windows.Forms.Control.OnClick(EventArgs e)
     at System.Windows.Forms.Button.OnClick(EventArgs e)
     at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
     at System.Windows.Forms.Control.WmMouseUp(Message&amp; m, MouseButtons button, Int32 clicks)
     at System.Windows.Forms.Control.WndProc(Message&amp; m)
     at System.Windows.Forms.ButtonBase.WndProc(Message&amp; m)
     at System.Windows.Forms.Button.WndProc(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message&amp; m)
     at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&amp; m)
     at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
  </code></pre>