Found this over on Noam Lampert’s blog, originally form monologue.
I remember running into this bug when writing a rather trivial outlook add-in that registered a toolbar on all new explorers. At the time I was so far under time pressure that I just caved and changed the toolbar installer to install it on all toolbars by default (worked around the bug). I didn’t think that it might be a garbage collection issue. Good spot by Noam and co.
Short version: Any new explorer callbacks will get garbage collected unless you actually create an explicit reference to the Application.Explorers that you manage in your add-in.
So you would replace this:
Application.Explorers.NewExplorer += new ExplorersEvents_NewExplorerEventHandler(Explorers_NewExplorer);
with this:
Explorers explorers = Application.Explorers;
explorers.NewExplorer += new ExplorersEvents_NewExplorerEventHandler(Explorers_NewExplorer);
Recent Comments