Calling Webservice from MS Word

J

jerry051

i develop a word addin using C#, and i add two CommandBar and some buttons &
menuItems on word toolbar & menuBar. when these buttons (or menuItems)
calling local method, it work correct and well. but once one button calling
a webservice method,(and that it return correct result), then all new
buttons & menuItems of my add then lost function. i don't know where is
wrong, please help me, thanks a lot.
 
P

Paul Qualls

This may seem like a hack, but I tried this to cure a similar problem and it
worked..

add a private member to your class (you will need to add collections to your
using statements)

private ArrayList al;

then when you create each button and menu items, add them to the ArrayList.
You don't have to do anything else with them after you add them, but this
for some reason keeps the events "aware" that they are supposed to stick
around.

al.Add(MyButton);
al.Add(MyMenuItem);

etc..

Let me know how this works out.

Paul
 
P

Paul Qualls

Paul Qualls said:
add a private member to your class (you will need to add collections to
your using statements)

private ArrayList al;

One additional note is that you will need to new() the ArrayList somewhere.
You can do it right in the declaration if you like like:

private ArrayList al = new ArrayList();



Paul
 
J

jerry051

thanks a lot to Paul,i know what's wrong.it's .NET GC arose. i rewrited my
code and using static varibles. after doing this over. it's all ok.
 
P

Paul Qualls

jerry051 said:
thanks a lot to Paul,i know what's wrong.it's .NET GC arose. i rewrited my
code and using static varibles. after doing this over. it's all ok.
yep...

that is what the ArrayList prevents. did you try that?


pq
 

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