I ran into an issue on Friday night while using the Infragistics controls within the scope of the Composite UI Application Block (CAB). My problem started when I tried to create a command with CAB from a UltraToolbarsManager tool using a function with a CommandHandler attribute that matched the signature of the event as shown below:
// statement within the work item
Commands["MyCommand"].AddInvoker(myTool, "ToolClick");
[CommandHandler("MyCommand")]
public void MyCommand(object sender, ToolClickEventArgs e)
{
// do something
}
The application compiles fine; however, at run-time you get an ArgumentException as soon as the class with the CommandHandler is added to the WorkItem. The message on the exception is "Error binding to target method." Internally, the CAB fails at CommandStrategy.CreateCommandHandler method.
After a little digging I determined that the EventArgs sub-classes such as ToolClickEventArgs are not serializable as is standard fare for EventArgs classes and that is apparently required by CAB. Typically in the case of a toolbar button click it will not matter, because all you care is what button was pushed. But, with the Infragistics UltraWinToolbars you can have different buttons such as a state button or a combo box button. In those cases you likely will need access to the state of the tool.
I opened up a support incident with Infragistics and this morning I was told that a feature request has been made. The feature request is FR11622 if you run into this same problem and want them to change it. At this point the request hasn't been committed to development, so please let them know if you need this too.
You can work-around this problem by changing the ToolClickEventArgs to EventArgs in your CommandHandler attributed method, but then you have to figure out a different way to get at the button state.