title: Why don't dynamic objects and extension methods play nice?
body: <p>The causes of the exception:</p>
  
  <blockquote>
    <p>Extension methods cannot be dynamically dispatched. Consider casting the dynamic arguments or calling the extension method without the extension method syntax.</p>
  </blockquote>
  
  <p>Have been covered in several SO questions (<a href="https://stackoverflow.com/questions/15391115/what-causes-extension-methods-cannot-be-dynamically-dispatched-here/15391292#15391292">here</a> and <a href="https://stackoverflow.com/questions/20932646/extension-methods-cannot-be-dynamically-dispatched">here</a> ).But no one has said why the Framework doesn't allow this:</p>
  
  <hr>
  
  <h2>Example</h2>
  
  <pre><code>public static class ExampleExtension
  {
      public static string HelloWorld(this object o, object o2)
      {
          return "Hello World";
      }
  
      public static void Test()
      {
          dynamic dynamicObject = new object();
  
          //Exception
          new object().HelloWorld(dynamicObject);
  
          //No Exception
          ExampleExtension.HelloWorld(new object(), dynamicObject);
      }
  }
  </code></pre>
  
  <hr>
  
  <blockquote>
    <p>new object().HelloWorld(dynamicObject)` <strong>is bad</strong></p>
  </blockquote>
  
  <hr>
  
  <blockquote>
    <p>ExampleExtension.HelloWorld(new object(), dynamicObject)` <strong>is good</strong></p>
  </blockquote>
  
  <hr>
  
  <h2>Why?</h2>
  
  <p>If extension methods are essentially just syntactic sugar for calling a static method, wouldn't <code>new object().HelloWolrd()</code> be converted to the compiler to <code>ExampleExtension.HelloWorld(new object())</code> anyway?  So why can't the <code>DLR</code> handle this?</p>