Menu events & access disappearing

D

David Thielen

Hello;

I've written about this twice before but now I just found another problem
with this. First off, the is a C# add-in under Word 2003 and my menu objects
are in global scope and therefore are not garbage collected.

In addition, if I start Word and bring up a document, it works 100%.

Problem 1 - under very repeatable conditions, I can get to a point where
setting CommandBarControl.Enabled, which previously worked fine, will
generate an exception. To work around this, I catch the exception and at that
time reassign that menu item to my object. I did not grab the menu event
again as that kept firing ok.

Problem 2 - When I first had this happen, I tried reassigning the menu
object on the Application.DocumentChange event as the exception would always
occur inside my handler for that event (thereby avoiding an exception).
However, when I did that, I would then lose my menu events. So this can only
be done when the exception is thrown.

Problem 3 - this is the one I can't work around - today I found that
sometimes when I reassing the menu objects, I then lose the menu events (ie
Problem 2). I have not been able to come up with a specific sequence to
reproduce it but I am 100% certain the events stopped firing.

Here's the problem. I can't always grab the menu events again when the
exception is thrown because usually I am still getting them and by doing this
I would get multiple events for a single menu click.

But I need to know when I will lose the events so in that case I can get the
event again.

Or better yet, a work around that avoids this bug altogether where my menu
objects are always pointing to the underlying COM menus.

Again, none of this happens if you open a single copy of Word and edit
documents in that one copy. It's multiple copies and documents being closed
in some that causes this. So it's quite possible that Microsoft's testing has
never hit these combinations (although I would hope so as it is pretty simple
use).

Any ideas?
 
P

Peter Huang

Hi

Now I am researching the issue, and I will update you with new information
ASAP.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
P

Peter Huang

Hi Dave,

I am sorry for delay response.
I have tried a lot but it seems that I can not reproduce the problem.
Would you please build a simple reproduce sample and send to me by removing
"online" from my email address? And so that we can try to see if there is
any other way to do the job.

A possible workaround I think you may try to recreate the menu button which
may cause the problem, so that after we dispose the menu item, and recreate
the button instance, the event handler's will also be disposed, so there
would not be such scenario that there will more than one event handlers
with one event.

If you still have any concern, please feel free to post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
D

David Thielen

This is in the sample code I sent you. I just emailed you a response on that.

thanks - dave
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top