Unregister COM add-in

Y

Yael

Hi,
I want to remove my button add-in to outlook 2003 from vs.net 2003.
I tried to write in vs.net command prompt:
regasm /u "C:\MyAddin\bin\Debug\MyAddin.dll"

the result of this is the button is still there (in outlook), but the event
of this button add-in is deleted..(if I click on my button, I don't get a msg
box as befor)
How to remove the button to??
Thank's,
Yael.
 
Y

Yael

I found that if I'm doing regasm /u my.dll
and in the outlook 2003:
ToolBor --> restart
then My add-in button is finally disappear!!!e add-in button
(If I don't doing the uninstall, in the next outlook opening - the add-in
button is appear)
1)So, It's OK?
2)How can I doing uninstall add-in by button clicked method? is it possible?
3)And if I do:
tools--> options-->other-->advanced options--< com Add-ins
why I can't see my add-in dll?
 
K

Ken Slovak - [MVP - Outlook]

Don't depend on removing any UI during uninstalling the addin, that's not a
best practice. Your addin should create any UI using the Temporary flag and
setting that flag true. Then as a precaution also delete your UI when the
Inspector or Explorer where it was created closes.

If you register your addin for all users (HKLM) it's an administrative
installation and therefore does not show up in the COM Add-Ins dialog
(except with Outlook 2007). Register the addin for current user (HKCU) if
you want it to show up in the COM Add-Ins dialog.
 
Y

Yael

Do you meen like this:
this.toolbarButton =
(CommandBarButton)commandBars["Standard"].Controls.Add(Type=constants.msoControlButton, Temporary=True);
the button still there after uninstall.
Do you have any example?
Thank you
 
Y

Yael

This is my code:
try
{
// See if it already exists
this.toolbarButton =
(CommandBarButton)commandBars["Standard"].Controls["Yael's AddIn"];
}
catch(System.Exception)
{
// Create it
this.toolbarButton =
(CommandBarButton)commandBars["Standard"].Controls.Add(1,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, true);
this.toolbarButton.Caption = "Yael's AddIn";
this.toolbarButton.Style = MsoButtonStyle.msoButtonCaption;
}
this.toolbarButton.Tag = "Yael's AddIn";
this.toolbarButton.OnAction = "!<MyAddin1.Connect>";
this.toolbarButton.Visible = true;
this.toolbarButton.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.OnToolbarButtonClick);
}
 
U

UK

Please send the code where you are deleting your button?? You might have
written some code to delete your button.

Yael said:
This is my code:
try
{
// See if it already exists
this.toolbarButton =
(CommandBarButton)commandBars["Standard"].Controls["Yael's AddIn"];
}
catch(System.Exception)
{
// Create it
this.toolbarButton =
(CommandBarButton)commandBars["Standard"].Controls.Add(1,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, true);
this.toolbarButton.Caption = "Yael's AddIn";
this.toolbarButton.Style = MsoButtonStyle.msoButtonCaption;
}
this.toolbarButton.Tag = "Yael's AddIn";
this.toolbarButton.OnAction = "!<MyAddin1.Connect>";
this.toolbarButton.Visible = true;
this.toolbarButton.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.OnToolbarButtonClick);
}
Ken Slovak - said:
Don't depend on removing any UI during uninstalling the addin, that's not a
best practice. Your addin should create any UI using the Temporary flag and
setting that flag true. Then as a precaution also delete your UI when the
Inspector or Explorer where it was created closes.

If you register your addin for all users (HKLM) it's an administrative
installation and therefore does not show up in the COM Add-Ins dialog
(except with Outlook 2007). Register the addin for current user (HKCU) if
you want it to show up in the COM Add-Ins dialog.
 
Y

Yael

public void OnBeginShutdown(ref System.Array custom)
{
this.toolbarButton.Delete(System.Reflection.Missing.Value);
this.toolbarButton = null;
}

Thank's aloooooot!!!
Yael

UK said:
Please send the code where you are deleting your button?? You might have
written some code to delete your button.

Yael said:
This is my code:
try
{
// See if it already exists
this.toolbarButton =
(CommandBarButton)commandBars["Standard"].Controls["Yael's AddIn"];
}
catch(System.Exception)
{
// Create it
this.toolbarButton =
(CommandBarButton)commandBars["Standard"].Controls.Add(1,
System.Reflection.Missing.Value, System.Reflection.Missing.Value,
System.Reflection.Missing.Value, true);
this.toolbarButton.Caption = "Yael's AddIn";
this.toolbarButton.Style = MsoButtonStyle.msoButtonCaption;
}
this.toolbarButton.Tag = "Yael's AddIn";
this.toolbarButton.OnAction = "!<MyAddin1.Connect>";
this.toolbarButton.Visible = true;
this.toolbarButton.Click += new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(this.OnToolbarButtonClick);
}
Ken Slovak - said:
Don't depend on removing any UI during uninstalling the addin, that's not a
best practice. Your addin should create any UI using the Temporary flag and
setting that flag true. Then as a precaution also delete your UI when the
Inspector or Explorer where it was created closes.

If you register your addin for all users (HKLM) it's an administrative
installation and therefore does not show up in the COM Add-Ins dialog
(except with Outlook 2007). Register the addin for current user (HKCU) if
you want it to show up in the COM Add-Ins dialog.




I found that if I'm doing regasm /u my.dll
and in the outlook 2003:
ToolBor --> restart
then My add-in button is finally disappear!!!e add-in button
(If I don't doing the uninstall, in the next outlook opening - the add-in
button is appear)
1)So, It's OK?
2)How can I doing uninstall add-in by button clicked method? is it
possible?
3)And if I do:
tools--> options-->other-->advanced options--< com Add-ins
why I can't see my add-in dll?
 
K

Ken Slovak - [MVP - Outlook]

The code for creating the bar as temporary is OK, although to my knowledge
C# doesn't support named arguments. But setting Temporary = true is exactly
what you need to do.

For deleting the UI by the time BeginShutdown fires it's too late. You need
to catch the Explorer and Inspector Close events and delete your UI there in
Close.

Deleting the UI is what I call a belt and suspenders technique. It really
shouldn't be necessary but is useful if an exception causes Outlook or your
addin to crash.

If your UI is still there when your addin is not running or after
uninstalling the addin that tells me that Outlook is not closing cleanly
when it's shut down and therefore isn't removing the temporary UI you added.
Why it's not closing cleanly is something else.

Make sure you are releasing all of your COM objects (Outlook and other) in
the appropriate Explorer and Inspector Close events. Make sure to call your
teardown or release code when the last Explorer fires its Close event
(Explorers.Count <= 1). Then in BeginShutdown you can check a flag to see if
the release code has been called, if not call it from BeginShutdown.

In some cases you may need to not only set your COM objects to null but also
to call Marshal.ReleaseComObject on them, call GC.Collect() and then call
GC.WaitForPendingFinalizers(). Otherwise Outlook may not close correctly if
the GC has not released your COM objects by the time Outlook is trying to
close.

Have you verified that you are actually receiving the BeginShutdown and
OnDisconnection events?
 
Y

Yael

Thank you for your replay..
I took my code from example,
So, why I have to add all this???
I'm not fully understood you,
do you have an example for this?
Thank's,
Yael
I add dlls:
System.Windows.Forms
Microsoft.Office.Interop.Outlook.dll
stdole.dll
office.dll
 
K

Ken Slovak - [MVP - Outlook]

I don't know what example you used and some of the samples just show the
basics and not all the glue code you need in the real world. See the
Explorer wrapper example at
http://www.outlookcode.com/codedetail.aspx?id=789 for a look at handling
Explorers, wrappers for Explorers, handling buttons and correct shutdown
procedures.
 

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