Let us consider im having an application named as AAA. Now Im Loading an assembly named as BBB.The aseembly BBB is having the declaration of event and delegate. The handler to the event in BBB is available in AAA. while loading the assembly BBB, i need to add the handler for the event in AAA. Whenever the event occurs in BBB, the handler method in AAA shoud gets executed automatically. How to accomplish this..........?
i coded like dis in AAA
Assembly tstComponent = Assembly.LoadFile(BBB);
Type Global = tstComponent.GetType(ClassInBBB, false, true);
if (Global != null)
{
EventInfo l_objevent = Global.GetEvent("OnGetdelInBBB");
Type l_objEveType = l_objevent.EventHandlerType;
Type Dis = Assembly.GetExecutingAssembly().GetType("AAA", false, true);
MethodInfo l_method = Dis.GetMethod("HandlerinAAA");
Delegate d = Delegate.CreateDelegate(l_objEveType, l_method);//Getting argument bind exception in this line
MethodInfo addHandler = l_objevent.GetAddMethod();
Object[] addHandlerArgs = { d };
addHandler.Invoke(Dis, addHandlerArgs);
}
please help me. Thanks in advance