In my application i need to load the com object dynamically. I implemented this by loading com by program id. It succeeded, also i could able to access methods and properties of dynamically loaded com. But in the case of event handling some problems occurred. Please find the following code
dynamic ocx = m_axCtrl.GetOcx(); // ocx dynamic loading
ocx.method1();//success
ocx.Event1+=new EventHandler<object>(EventHandler1);
ocx.Event2+=new EventHandler<object>(EventHandler2);
public void EventHandler1(object sender , object e) // e is type of class1
{
}
public void EventHandler2(object sender , object e) // e is type of class2
{
}
public class class1
{
public string arg1;
public string arg2;
}
public class class2
{
public string arg1;
public string arg2;
public string arg3;
public string arg4;
public string arg5;
public string arg6;
}
Here my first event will fire and the last won't fire.I think it is due to the mis match of event arguments. What are the things needs to handle when creating event handlers of above types. Please help me.