Hi all,
I am loading three Assemblies dynamically using Assembly.LoadFrom()
e g -: Assembly *** = Assembly.LoadFrom(“Test.dll”);
First assembly contains just an event inside the class.
Eg-: public delegate int Maths(int a, int b);
public event Maths mathsEvent;
Other two dlls contain classes with functions which will return int and will take two integer type parameters.
After loading the assemblies dynamically
am getting the event of the first assembly in EventInfo object using typeObject.GetEvent(“mathsEvent”);
Eg -:
Type[] type = ***.GetTypes();
EventInfo einfo type.GetEvent(“mathsEvent”);
Then I am getting the types of the other two dlls on after the other in a for loop and
Eg -: Type[] types = ***.GetTypes();
The creating the object of the class inside the DLLs using Activator.CreateInstance()(Please let me know if there is any other way to create the class directly)
Eg -: object obj = Activator.CreateInstance(typ);
Then I am getting the informations of the method in the MethodInfo class object.
Eg -: MethodInfo mi = typ.GetMethod(fun
);
Then I am creating the delegate object using Delegate.CreateDelegate()
Eg -: Delegate de = Delegate.CreateDelegat(einfo.EventHandlerType, obj, mi);
Then I am adding the delegate to the EventInfo object using the AddEventHandler();
Eg -: einfo.AddEventHandler(obj,de);
Now my Question is how to raise the event using the EventInfo object, just like how we are raising the event using the event object,
Eg -: We can raise the event by using the event object mathsEvent(public event Maths mathsEvent;)using the mathsEvent(10,20;),it is not possible to use einfo(10,20), then which is the way.
Or else if there any other way to achieve the same.
Please help me.
With Regards,
Anand T.S

How to Raise an event using the EventInfo class object??
EricVB
You can only raise the event from inside the class that declares it, not through EventInfo (at least not for events declared in C#). Can you add a method to the class with with the event that will raise it for you and call that method instead