Ver versión en español    
 
Home
10 Reasons to use MZ-Tools
MZ-Tools 6.0 for VS.NET
Editions
Features
Online Documentation
MZ-Tools SDK
Download
Purchase
Version History (RSS)  
FAQ & Support
MZ-Tools 3.0 for VB6 & VBA
Features
Online Documentation
Download (freeware)
Donations (Paypal)
Version History (RSS)  
FAQ & Support
User Reviews
Community Place
Contact  
For Add-In Developers
About
   
 
User Testimonials

I'm an avid supporter of MZ-Tools. It's a product I couldn't do without and your level of support is outstanding.

Jan Hyde (Visual Basic MVP)

You will soon wonder how you ever lived without it.

Andy Maggs

More user reviews
 
BUG: Command events fired only to last addin loaded in Visual Studio .NET

Author: Carlos J. Quintero (Microsoft MVP) Applies to: Microsoft Visual Studio .NET 2002
Date: April 2004   Microsoft Visual Studio .NET 2003
       
Introduction

When two add-ins set event handlers to the same command of the Visual Studio .NET IDE, only the last one loaded receives events from that command.

Cause

This is a bug of Visual Studio .NET.

More Information

Steps to reproduce the problem:

  • Create two add-ins with the code (VB.NET) below. Each add-in shows a message when connected and each one should show a message when the user clicks the Help \ About menu. However, only the last loaded add-in shows the second message.
Private m_objAddIn As AddIn
Private WithEvents m_objAboutCommandEvents As EnvDTE.CommandEvents

Public Sub OnConnection(ByVal application As Object, _
   ByVal connectMode As Extensibility.ext_ConnectMode, _
   ByVal addInInst As Object, ByRef custom As System.Array) _
   Implements Extensibility.IDTExtensibility2.OnConnection

   Dim objDTE As EnvDTE.DTE
   Dim objCommand As Command

   objDTE = CType(application, EnvDTE.DTE)
   m_objAddIn = CType(addInInst, EnvDTE.AddIn)
   objCommand = objDTE.Commands.Item("Help.About")
   m_objAboutCommandEvents = objDTE.Events.CommandEvents(objCommand.Guid, objCommand.ID)

   MessageBox.Show("Addin " & m_objAddIn.Name & " connected")

End Sub

Private Sub m_objAboutCommandEvents_BeforeExecute(ByVal Guid As String, ByVal ID As Integer, _
   ByVal CustomIn As Object, ByVal CustomOut As Object, ByRef CancelDefault As Boolean) _
   Handles m_objAboutCommandEvents.BeforeExecute

   MessageBox.Show("Before showing about window from addin " & m_objAddIn.Name)

End Sub

Go back to the 'Resources for Visual Studio .NET extensibility' section for more articles like this

MZ-Tools 6.0 for Visual Studio .NET

You can code, design, locate code and document your apps much faster using VB.NET, C#, C++ or Visual J#:

Buy MZ-Tools Now Download MZ-Tools Demo

   Top