title: C# 4.0 'dynamic' doesn't set ref/out arguments
body: <p>I'm experimenting with <code>DynamicObject</code>.  One of the things I try to do is setting the values of <code>ref</code>/<code>out</code> arguments, as shown in the code below.  However, I am not able to have the values of  <code>i</code> and <code>j</code> in <code>Main()</code> set properly (even though they are set correctly in <code>TryInvokeMember()</code>).  Does anyone know how to call a <code>DynamicObject</code> object with <code>ref</code>/<code>out</code> arguments and be able to retrieve the values set inside the method?</p>
  
  <pre><code>class Program
  {
      static void Main(string[] args)
      {
          dynamic proxy = new Proxy(new Target());
          int i = 10;
          int j = 20;
          proxy.Wrap(ref i, ref j);
          Console.WriteLine(i + ":" + j); // Print "10:20" while expect "20:10"
      }
  }
  
  class Proxy : DynamicObject
  {
      private readonly Target target;
  
      public Proxy(Target target)
      {
          this.target = target;
      }
  
      public override bool TryInvokeMember(InvokeMemberBinder binder, object[] args, out object result)
      {
          int i = (int) args[0];
          int j = (int) args[1];
          target.Swap(ref i, ref j);
          args[0] = i;
          args[1] = j;
          result = null;
          return true;
      }
  }
  
  class Target
  {
      public void Swap(ref int i, ref int j)
      {
          int tmp = i;
          i = j;
          j = tmp;
      }
  }
  </code></pre>
  
  <p><strong>Update 7/15:</strong>
  Microsoft claims to have fixed the issue for the next release of .NET <a href="http://connect.microsoft.com/VisualStudio/feedback/details/543101/net-4-0s-dynamicobject-doesn-t-set-ref-out-arguments" rel="nofollow noreferrer">http://connect.microsoft.com/VisualStudio/feedback/details/543101/net-4-0s-dynamicobject-doesn-t-set-ref-out-arguments</a></p>
  
  <p><strong>Update 9/8/2012:</strong>
  Tested using VS.NET 2012 with both .NET 4.0 and 4.5, confirm: it's already fixed.</p>