title: InvalidCastException when calling Dictionary.TryGetValue(String, out object). Why?
body: <p>I'm at a loss.  I have a Dictionary object with String keys.  The objects are of a custom type I have.  This example throws an InvalidCastException:</p>
  
  <pre><code>MyObject temp;
  if(Dict.TryGetValue("abc", out temp)) //exception
  </code></pre>
  
  <p>If I instead use "ContainsKey", I still get an InvalidCastException:</p>
  
  <pre><code>if(Dict.ContainsKey("abc")) //exception
  </code></pre>
  
  <p>In both cases, if I put a watch on Dict["abc"], I get the value that I want from the Dictionary.  The Exception details provide no extra information.</p>
  
  <p>I tried putting together a small code sample that replicates this situation, but my code samples work perfectly.  I don't know how to provide a code sample for this problem.</p>
  
  <p>Why would I get an InvalidCastException when checking for the existence of a key in a Dictionary?  Why does ContainsKey even need to do any casting in its implementation?  How do I fix this?</p>