title: System.Dynamic bug?
body: <p>While I playing with the C# 4.0 dynamic, I found strange things happening with the code like this:</p>
  
  <pre><code>using System.Dynamic;
  
  sealed class Foo : DynamicObject
  {
      public override bool TryInvoke(
          InvokeBinder binder, object[] args, out object result)
      {
          result = new object();
          return true;
      }
  
      static void Main()
      {
          dynamic foo = new Foo();
  
          var t1 = foo(0);
          var t2 = foo(0);
          var t3 = foo(0);
          var t4 = foo(0);
          var t5 = foo(0);
      }
  }
  </code></pre>
  
  <p>Ok, it works but... take a look at IntelliTrace window:</p>
  
  <p><a href="http://img717.imageshack.us/img717/4914/10435230.png">screenshot http://img717.imageshack.us/img717/4914/10435230.png</a></p>
  
  <p>So every invokation (and other operations too on dynamic object) causes throwing and catching strange exceptions twice!</p>
  
  <p>I understand, that sometimes exceptions mechanism may be used for optimizations, for example first call to dynamic may be performed to some stub delegate, that simply throws exception - this may be like a signal to dynamic binder to resolve an correct member and re-point delegate. Next call to the same delegate will be performed without any checks.</p>
  
  <p>But... behavior of the code above looks very strange. Maybe throwing and catching exceptions twice per any operation on DynamicObject - is a bug?</p>