Created
November 2, 2012 20:19
-
-
Save anonymous/4004086 to your computer and use it in GitHub Desktop.
Recreation of RX call to CreateDelegate that throws an exception.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace CreateDelegateTest | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Create the shim. | |
var shim = new Shim(); | |
// Create the delegate. | |
var ev = (EventHandler<EventArgs>)Delegate.CreateDelegate(typeof(EventHandler<EventArgs>), | |
new Action<EventArgs>(shim.Next), | |
typeof(Action<EventArgs>).GetMethod("Invoke")); | |
ev(null, EventArgs.Empty); | |
} | |
} | |
public class Shim | |
{ | |
public void Next(EventArgs e) | |
{ | |
Console.WriteLine("Fired"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment