mysterious "Object reference not set to an instance of object"
<p>I understand what the error means but it's quite strange I couldn't possibly think of any reasons,
Here is my simplified structure:</p>

<pre><code> public partial class mainForm : Form
{
    public mainForm()
    {
        InitializeComponent();
        IgnoreList = new SortedSet&lt;string&gt;();
        IgnoreListQueue IgnoreQueue = new IgnoreListQueue();
    }
    public class IgnoreListQueue
    {
        private Dictionary&lt;string, int&gt; myQueue;
        public void Add(string s)
        {
        }
        public IgnoreListQueue()
        {
            myQueue = new Dictionary&lt;string, int&gt;();
        }
        public bool contains()
        {}
        ~IgnoreListQueue()
        {
        }
    }
    public SortedSet&lt;string&gt; IgnoreList;
    public IgnoreListQueue IgnoreQueue;
    public int LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam)
    {
        //IgnoreList is fine here
        //IgnoreQueue is null here.
                    //Example:
                    // bool boo = IgnoreQueue.contains(some string);
    }
}
</code></pre>

<p>In LowLevelKeyboardProc() function, IgnoreQueue was seen as null, and when VS debugged the crash, it really showed IgnoreQueue a null pointer..<br>
As my program hooks Keyboard strokes so I wasn't able to set breakpoint in the LowLevelKeyboardProc() function. However, I was able to breakpoint in the mainForm() constructor and showed that IgnoreQueue was indeed initialized and loaded some data at that point.<br>
Any ideas please ?</p>
