You're trying to add event handler and mess up with parameters. Adding an event handler won't help you. You don't need to touch the invocation list of the event handler, you need to raise the event.
Using
GetEvent
, you already got the instance of the class
System.Reflection.EventInfo
. Now you need to raise it. Your next step is to call
System.Reflection.EventInfo.GetRaiseMethod
of the type
System.Reflection.MethodInfo
and call this method using Reflection method invocation. You should expect the method with two parameters (and one hidden parameter is "self" which is the instance of the declaring class, this is your
Instance
variable you already initialized): sender of the object type and event arguments of the type
System.EventArgs
or a derived class.
You can find out the signature of the raise method by using
System.Reflection.MethodInfo.GetParameters
, the type and other properties of each parameter using the class
System.Reflection.ParameterInfo
.
You can invoke the raise method using
System.Reflection.MethodInfo.Invoke
. That will be your last step in raising the instance of the event with the parameters you provide.
For further detail, see:
http://msdn.microsoft.com/en-us/library/system.reflection.methodinfo.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.reflection.parameterinfo.aspx[
^].
—SA