title: AddEventHandler when event handler argument is object in method
body: <p>I have a Windows Phone page (MainPage), and in the codebehind, I want to dynamically add an event handler - for example to the MouseEnter event. The trick is, I want this event handler to have the event argument as an object: </p>
  
  <pre><code>    private void MyEventHandler(object sender, object args)
      {
  
      }
  </code></pre>
  
  <p>(The reason for this is that this is a simplified example)</p>
  
  <p>This works: </p>
  
  <pre><code>this.MouseEnter += MyEventHandler;
  </code></pre>
  
  <p>But this throws an ArgumentException:</p>
  
  <pre><code>var handlerType = Type.GetType("System.EventHandler`1").
                    MakeGenericType(typeof(EventArgs));
  this.GetType().GetEvent("Hold").AddEventHandler(
                    this, Delegate.CreateDelegate(handlerType, this, "MyEventHandler"));
  </code></pre>
  
  <p>And the message of the exception is:
  "Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type." If I change the signature of the event handler, all works, but I want to keep it as "object" or "dynamic". </p>
  
  <p>How can I add the event handler with the AddEventHandler call? </p>
  
  <p>Any help is highly appreciated.</p>