The samples in the "\NetOffice 1.7.3\NET 4.0\Examples\Excel\VB\NetOffice COMAddin Examples" directory work correctly. I believe I was misled by the project created by the "New Project Wizard" contained in the "Developers Toolbox" application that you provide. Among the classes created by that wizard, the constructor of the Addin object adds the event handlers for the events OnStartupComplete and OnDisconnection.
When I remove these lines from the constructor, the doubling up disappears. I post this fix to clarify to others that may be mystified why this happens. I do think it would be good if you could update the wizard to not add those extra handlers. Thanks.
Public Class Addin
Inherits Excel.Tools.COMAddin
Public Sub New()
Dim onStartupCompleteHandler As OnStartupCompleteEventHandler = AddressOf Me.Addin_OnStartupComplete
AddHandler Me.OnStartupComplete, onStartupCompleteHandler
Dim onDisconnection As OnDisconnectionEventHandler = AddressOf Me.Addin_OnDisconnection
AddHandler Me.OnDisconnection, onDisconnection
End Sub
Based on reading the other samples, it looks like the the constructor of the add-in should be empty. The NetOffice COMAddin class already implements IDTExtensibility2 and apparently the Addin_OnStartupComplete is already wired up to handle the event when you inherit from the COMAddin class. When the constructor was adding a handler, it was really adding a second one. That is why the OnStartupComplete handler was running twice. That routine running twice was then adding handlers for other events twice, doubling up their handler count (which can be seen in the private fields of the NetOffice Application object).When I remove these lines from the constructor, the doubling up disappears. I post this fix to clarify to others that may be mystified why this happens. I do think it would be good if you could update the wizard to not add those extra handlers. Thanks.