J
Joseph Geretz
I'm porting a C# Outlook Addin originally engineered as a COM Addin over to
use VSTO. I've gotten this to the point where my VSTO Addin installs its
Menu items and Toolbar buttons when Outlook launches. I've wired up my event
handler to each Menu item and toolbar button. (I use the same Event handler
and I use the Tag property which is different for every Menu Item and
Toolbar buton to determine which menu or button is being clicked and to take
appropriate action. This worked fine for me previously.)
However I'm seeing a very strange behavior: My event handler is fired for
the first toolbar or menu click. But then it never fires thereafter. It's
like after it fires once, it gets 'unhooked' form the event its supposed to
be handling. A breakpoint set in this handler isn't tripped.
Here's the code which wires up the Event handler:
tbButton.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(this.User_Click);
MenuItem.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(this.User_Click);
Here's the Event handler which fires once:
private void User_Click(Office.CommandBarButton cmdButton, ref bool cancel)
{
MessageBox.Show("Hello!");
}
Have you seen anything like this before? Is there something I need to do to
'reset' the Event handler after it completes? I'm completely puzzled. Bear
in mind that this was working beautifully when running as a COM Addin.
Thanks for your help,
- Joseph Geretz -
use VSTO. I've gotten this to the point where my VSTO Addin installs its
Menu items and Toolbar buttons when Outlook launches. I've wired up my event
handler to each Menu item and toolbar button. (I use the same Event handler
and I use the Tag property which is different for every Menu Item and
Toolbar buton to determine which menu or button is being clicked and to take
appropriate action. This worked fine for me previously.)
However I'm seeing a very strange behavior: My event handler is fired for
the first toolbar or menu click. But then it never fires thereafter. It's
like after it fires once, it gets 'unhooked' form the event its supposed to
be handling. A breakpoint set in this handler isn't tripped.
Here's the code which wires up the Event handler:
tbButton.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(this.User_Click);
MenuItem.Click += new
Office._CommandBarButtonEvents_ClickEventHandler(this.User_Click);
Here's the Event handler which fires once:
private void User_Click(Office.CommandBarButton cmdButton, ref bool cancel)
{
MessageBox.Show("Hello!");
}
Have you seen anything like this before? Is there something I need to do to
'reset' the Event handler after it completes? I'm completely puzzled. Bear
in mind that this was working beautifully when running as a COM Addin.
Thanks for your help,
- Joseph Geretz -