Since the Visual Test 4.0 copy that I have does not support C# UI elements so well, I set out to write my own eventhandlers for activating (and getting statuses) for GUI elements on other forms. I am able to handle buttons and all quite okay, but it is when I try to work with toolbar buttons that pop up "File Open" dialogs that I am transported to a wierd world....

Here is what I azm trying to do ...
1. Call another app from my app using reflection.
2. On clicking a button on my test app, a button on my other form, testForm, is clicked.
private void button2_Click(object sender, System.EventArgs e)
{

ToolBarButton btn = new ToolBarButton();
btn.Tag = "loadTemplateBut";
System.Windows.Forms.ToolBarButtonClickEventArgs k_btn = new System.Windows.Forms.ToolBarButtonClickEventArgs(btn);

k_btn.Button.Tag = "loadTemplateBut";
object[] p = {this, new ToolBarButtonClickEventArgs(btn)};//k_btn};
InvokeMethod(testForm ,"toolBar1_ButtonClick",p);
//InvokeMethod(testForm ,"closeBut_Click",p);

}

3. Invokemethod is
private void InvokeMethod(Form form, string methodName, params object[] parms)
{
:
:
:

ToolBarButtonClickEventHandler tbceh = (ToolBarButtonClickEventHandler)Delegate.CreateDelegate(typeof (ToolBarButtonClickEventHandler),form,methodName);
// ToolBar.ToolBarButtonCollection = (ToolBar.ToolBarButtonCollection)GetProperty(
// EventHandler tbceh = (EventHandler)Delegate.CreateDelegate(typeof (EventHandler),form ,methodName);
// form.Invoke(tbceh);
// form.Invoke(tbceh, parms);

if (tbceh != null)
{
form.Focus();
//form.Invoke(tbceh, parms);
form.Invoke(tbceh,parms);

}

}

The button1_click on the actual app simply opens a "FileOpen" dialog.

4. It is here that the app simply hangs. Instead of popping up the "FileOpen" dialog, if I activate a messagebox that works fine.

Any help to modify this or an alternative would be greatly appreciated.