title: IndexOutOfRangeExpection occurs on Dictionary.Add method
body: <p>I am getting an IndexOutOfRange exception while adding values to Generic dictionary (WinRT C#). Below is my code and stack trace of exception.</p>
  
  <p>Code:</p>
  
  <pre><code>if (!data.TryGetValue(index, out cells))
  {
     cells = new CellCollection();
     data.Add(index, cells);
  }
  </code></pre>
  
  <p>Stack trace:</p>
  
  <blockquote>
    <p>at System.Collections.Generic.Dictionary<code>2.Insert(TKey key, TValue value, Boolean add)
      at System.Collections.Generic.Dictionary</code>2.Add(TKey key, TValue value)</p>
  </blockquote>
  
  <p>I wouldn't expect this out of range exception occurs while adding. My application uses single thread only. 
  I have add values to dictionary and remove it from dictionary using GC.Collect() if not needed. And then add the value if needed.</p>
  
  <p>Can anyone give any suggestion to resolve this exception?</p>