The OnMacrosRuntimeReset event does not fire when you load a macro in Visual Studio 2005 or in Visual Studio .NET (833897)



The information in this article applies to:

  • Microsoft Visual Studio 2005 Standard Edition
  • Microsoft Visual Studio 2005 Professional Edition
  • Microsoft Visual Studio .NET (2003), Professional Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2003), Academic Edition
  • Microsoft Visual Studio .NET (2002), Professional Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Architect Edition
  • Microsoft Visual Studio .NET (2002), Enterprise Developer Edition
  • Microsoft Visual Studio .NET (2002), Academic Edition

SYMPTOMS

In Microsoft Visual Studio 2005 or in Microsoft Visual Studio .NET, the OnMacrosRuntimeReset event does not fire when you load a macro. The OnMacrosRuntimeReset event does fire when you unload the macro.

STATUS

This behavior is by design.

MORE INFORMATION

Steps to reproduce the behavior

  1. Start Visual Studio 2005 or Visual Studio .NET.
  2. On the View menu, point to Other Windows, and then click Macro Explorer.
  3. In the Macro Explorer window, expand MyMacros, right-click the Module1 module, and then click Edit.
  4. In the Project Explorer pane, double-click on the EnvironmentEvents.vb file.
  5. Replace the code in the EnvironmentEvents.vb file with the following code:
    Option Strict Off
    Option Explicit Off
    Imports EnvDTE
    Imports System.Diagnostics
    Imports System.ContextStaticAttribute
    
    Public Module EnvironmentEvents
        Public WithEvents TextEditorEvents As EnvDTE.TextEditorEvents
    
        Public Sub DTEEvents_OnMacrosRuntimeReset() Handles DTEEvents.OnMacrosRuntimeReset
            TextEditorEvents = DTE.Events.TextEditorEvents
            MsgBox("Hello!")
        End Sub
    #Region "Automatically generated code, do not modify"
        'Automatically generated code, do not modify
        'Event Sources Begin
        <System.ContextStaticAttribute()> Public WithEvents DTEEvents As EnvDTE.DTEEvents
        <System.ContextStaticAttribute()> Public WithEvents DocumentEvents As EnvDTE.DocumentEvents
        <System.ContextStaticAttribute()> Public WithEvents WindowEvents As EnvDTE.WindowEvents
        <System.ContextStaticAttribute()> Public WithEvents TaskListEvents As EnvDTE.TaskListEvents
        <System.ContextStaticAttribute()> Public WithEvents FindEvents As EnvDTE.FindEvents
        <System.ContextStaticAttribute()> Public WithEvents OutputWindowEvents As EnvDTE.OutputWindowEvents
        <System.ContextStaticAttribute()> Public WithEvents SelectionEvents As EnvDTE.SelectionEvents
        <System.ContextStaticAttribute()> Public WithEvents BuildEvents As EnvDTE.BuildEvents
        <System.ContextStaticAttribute()> Public WithEvents SolutionEvents As EnvDTE.SolutionEvents
        <System.ContextStaticAttribute()> Public WithEvents SolutionItemsEvents As EnvDTE.ProjectItemsEvents
        <System.ContextStaticAttribute()> Public WithEvents MiscFilesEvents As EnvDTE.ProjectItemsEvents
        <System.ContextStaticAttribute()> Public WithEvents DebuggerEvents As EnvDTE.DebuggerEvents
        'Event Sources End
        'End of automatically generated code
    #End Region
    End Module
  6. Save the MyMacros macro project.
  7. In the Macro Explorer pane, right-click MyMacros project, and then click Unload Macro Project.

    Note If the MyMacros project is set as the recording project, create a new macro project, and then set it as the recording project.
  8. In the Macro Explorer pane, right-click Macros, and then click Load Macro Project to load the MyMacros project. A warning message is shown.
  9. In the Warning message box, click Enable event handling code, and then click OK.
  10. Perform step 7. The OnMacrosRuntimeReset event is fired two times. Click OK two times to close the two message boxes that display.
  11. Perform step 8 and step 9. Notice that the OnMacrosRuntimeReset event is not fired.

REFERENCES

For more information, visit the following Microsoft Developer Network (MSDN) Web site:http://msdn.microsoft.com/library/en-us/vsintro7/html/vxtskManagingMacros.asp

Modification Type:MajorLast Reviewed:3/4/2006
Keywords:kbvs2005swept kbvs2005applies kbmacro kbEvent kbprb KB833897 kbAudDeveloper