N
ningxia
hi,guys, i develop a word addin, everything is right except when deleting
addin buttons & menus in OnDisconnection() method when dubuging. this is my
code :
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
......
private CommandBar cb;
private static CommandBarButton btnLogin;
......
}
.......
public void OnDisconnection(Extensibility.ext_DisconnectMode
disconnectMode, ref System.Array custom)
{
if(disconnectMode !=
Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
{
OnBeginShutdown(ref custom);
}
}
public void OnBeginShutdown(ref System.Array custom)
{
CommandBarButton btnLogin =
(CommandBarButton)wdApp.CommandBars.FindControl(oMissing,oMissing,"btnLogin"
,oMissing);
if (btnLogin != null)
{
btnLogin.Visible = false;
btnLogin.Click -= new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnLogin_Cli
ck);
btnLogin.Delete (System.Reflection.Missing.Value);
Marshal.ReleaseComObject (btnLogin);
}
cb.Delete();
Marshal.ReleaseComObject(cb);
}
every time when i debuging, i could aways catch exceptions such as "object
no reference......".
I wonder how to correctly delete addin buttons & menus in OnBeginShutdown()
method? please help me ,thanks a lot.
addin buttons & menus in OnDisconnection() method when dubuging. this is my
code :
public void OnConnection(object application, Extensibility.ext_ConnectMode
connectMode, object addInInst, ref System.Array custom)
{
......
private CommandBar cb;
private static CommandBarButton btnLogin;
......
}
.......
public void OnDisconnection(Extensibility.ext_DisconnectMode
disconnectMode, ref System.Array custom)
{
if(disconnectMode !=
Extensibility.ext_DisconnectMode.ext_dm_HostShutdown)
{
OnBeginShutdown(ref custom);
}
}
public void OnBeginShutdown(ref System.Array custom)
{
CommandBarButton btnLogin =
(CommandBarButton)wdApp.CommandBars.FindControl(oMissing,oMissing,"btnLogin"
,oMissing);
if (btnLogin != null)
{
btnLogin.Visible = false;
btnLogin.Click -= new
Microsoft.Office.Core._CommandBarButtonEvents_ClickEventHandler(btnLogin_Cli
ck);
btnLogin.Delete (System.Reflection.Missing.Value);
Marshal.ReleaseComObject (btnLogin);
}
cb.Delete();
Marshal.ReleaseComObject(cb);
}
every time when i debuging, i could aways catch exceptions such as "object
no reference......".
I wonder how to correctly delete addin buttons & menus in OnBeginShutdown()
method? please help me ,thanks a lot.