title: Creating a Delegate from methodInfo in Mono 2.8.2
body: <p>Hi I am trying to create a messenger in Mono 2.8.2 - the subset used by Unity3d. I thought it would be nifty to create a helper to auto subscribe methods to the messenger when they are decorated with a "subscribe" attribute.</p>
  
  <p>I've been scratching my head over this and have read many of the other related stack questions without a solution to my problem. <a href="http://lists.ximian.com/pipermail/mono-bugs/2010-December/106824.html" rel="noreferrer">Frankly, I don't know if I am doing something wrong or if this is a bug in Mono.</a></p>
  
  <pre><code>foreach (var methodInfo in methods)
          {
              var attr = methodInfo.GetAttribute&lt;SubscribeAttribute&gt;();
              if (attr == null)
                  continue;
  
              var parmas = methodInfo.GetParameters();
              if (parmas.Length != 1)
              {
                  Debug.LogError("Subscription aborted. Invalid paramters.");
                  continue;
              }
  
              var type = parmas[0].ParameterType;
  
              // Crashes here
              // ArgumentException: method argument length mismatch
              // I have tried many combinations.. 
              // Direct typing of the message type and dynamic typing
  
              var action = (Action&lt;object&gt;)Delegate.CreateDelegate(typeof(Action&lt;object&gt;), methodInfo);
  
               // also does not work
               // var dt = Expression.GetActionType(parmas.Select(o =&gt; o.ParameterType).ToArray());
               // var action = Delegate.CreateDelegate(dt, methodInfo);
  
              Subscribe(type, action, instance);
          }
  </code></pre>
  
  <p>Any suggestions or work around would be appreciated.</p>
  
  <p><strong>Edit</strong>
  The method signature looks like :</p>
  
  <pre><code>[Subscribe]
  void OnMessage(object message){
    // Hello World
  }
  </code></pre>
  
  <p>Though, it was originally...</p>
  
  <pre><code>[Subscribe]
  void OnTestMessage(TestMessage message){
    // Hello World
  }
  </code></pre>