Outlook addin commandbarButton respawns??

K

Kenneth

Hi,
I am writing an add in for Outlook 2003 with VS.NET 2003 in C#. The add in
creates a new command bar button. it installs and runs fine but the button
respawns every time outlook is opened so that after opening outlook 4 times
you have four copies of the button. It also does not remove the button when
you uninstall the add in. here is what I am doing:

OnStartupComplete(ref System.Array custom){
CommandBars = ApplicationObject.ActiveExplorer().CommandBars;
try{
myButton = (CommandBarsButton) commandBars["Standard"].Control("task");
}
catch(e){
myButton = (CommandBarsButton)commandBar"Standard"].Add

(1,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System.Reflection.Missing.Value);
myButton.Caption = "task";
myButton.Style = MsoButtonStyle.msoButtonCaption;
}
myButton.Tag = "task";
myButton.Visible = true;
}


OnBeginShutdown(ref System.Array custom){
myButton.Delete(System.Reflection.Missing.Value);
GC.Collect();
}

onDisConnection("you know whats here"){
if(disconnectMode !=
Extensibility.ext_DisconnectMode.ext_dm_HoatShutdown){
OnBeginShutdown(ref custom);
}
myButton.Delete(System.Reflection.Missing.Value);
GC.Collect();
}

why is my button not deleted when i close outlook or remove the addin?
 
S

Sue Mosher [MVP-Outlook]

Best practice is to create a custom toolbar or add a button to a built-in toolbar with its Temporary parameter set to True, not System.Reflection.Missing.Value.
 
K

Kenneth

Yes. Thanks a lot.

Sue Mosher said:
Best practice is to create a custom toolbar or add a button to a built-in toolbar with its Temporary parameter set to True, not System.Reflection.Missing.Value.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Kenneth said:
Hi,
I am writing an add in for Outlook 2003 with VS.NET 2003 in C#. The add in
creates a new command bar button. it installs and runs fine but the button
respawns every time outlook is opened so that after opening outlook 4 times
you have four copies of the button. It also does not remove the button when
you uninstall the add in. here is what I am doing:

OnStartupComplete(ref System.Array custom){
CommandBars = ApplicationObject.ActiveExplorer().CommandBars;
try{
myButton = (CommandBarsButton) commandBars["Standard"].Control("task");
}
catch(e){
myButton = (CommandBarsButton)commandBar"Standard"].Add

(1,System.Reflection.Missing.Value,System.Reflection.Missing.Value,System..Reflection.Missing.Value,System.Reflection.Missing.Value);
myButton.Caption = "task";
myButton.Style = MsoButtonStyle.msoButtonCaption;
}
myButton.Tag = "task";
myButton.Visible = true;
}


OnBeginShutdown(ref System.Array custom){
myButton.Delete(System.Reflection.Missing.Value);
GC.Collect();
}

onDisConnection("you know whats here"){
if(disconnectMode !=
Extensibility.ext_DisconnectMode.ext_dm_HoatShutdown){
OnBeginShutdown(ref custom);
}
myButton.Delete(System.Reflection.Missing.Value);
GC.Collect();
}

why is my button not deleted when i close outlook or remove the addin?
 

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