Programming Application Verifier

Application Verifier has a set of programmable hooks through the Development Tools Extensibility (DTE) model. The purpose of this model is to help you extend and automate tasks within Visual Studio 2005. The main interop assembly that exposes Application Verifier's automation model is Microsoft.VisualC.ApplicationVerifier.dll.

Using DTE, you can perform a variety of tasks, including programmatically creating tools and toolbars, responding to events, and launching commands. In many cases, when there is output to be displayed on the screen, it is shown in the Command window. You can access this window by clicking View image from book Other Windows image from book Command Window (or CTRL+ALT+A).

In this section, you'll create a Visual Studio 2005 macro that automatically launches Application Verifier. Here are the steps to build your project:

  1. Select Tools image from book Macros image from book New Macro Project from the main toolbar.

  2. This will open the New Macro Project dialog box (shown in Figure 10-11).

    image from book
    Figure 10-11

  3. Select a name for your macro and click the Add button

  4. The Macro Explorer window will appear (as shown in Figure 10-12).

    image from book
    Figure 10-12

  5. Double-clicking on Module1 will launch the Visual Studio Macros IDE (as shown in Figure 10-13). It should be split between the Project Explorer window and the Code window. To access the Project Explorer, click View image from book Project Explorer.

    image from book
    Figure 10-13

  6. Enter the following code and click the Save icon.

          Imports System      Imports EnvDTE      Imports EnvDTE80      Imports System.Diagnostics      Public Module Module1         Sub AppVerifMacro()           DTE.ExecuteCommand("Debug.StartWithApplicationVerifier")         End Sub      End Module 

When you open the Macro IDE, you'll notice that the EnvDTE, EnvDTE80, and System.Diagnostic namespaces are already in place for you. All you have to add is the System namespace. On Line 8 of the application, we execute Debug.StartWithApplicationVerifier using the automation model. Note that Debug.StartWithApplicationVerifier is an alias for the actual UI command. You can also launch this command using the Command window by typing the following:

      > Debug.StartWithApplicationVerifier 

Two major command aliases are available through the Application Verifier automation model. The latter command will open the tool window. This is very useful if you want Application Verifier to output the results of the debug session:

  • Debug.StartWithApplicationVerifier

  • Debug.ApplicationVerifierStopData

For more information about event handling and programming Application Verifier, you have two primary sources. You can go spelunking into Microsoft.VisualC.ApplicationVerifier.dll (using Lutz Roeder's Reflector available at to do some trial-and-error exploration (one of the best ways to learn). Alternately, you can refer to the MSDN Library available alongside Visual Studio 2005.

Professional Visual Studio 2005 Team System
Professional Visual Studio 2005 Team System (Programmer to Programmer)
ISBN: 0764584367
EAN: 2147483647
Year: N/A
Pages: 220 © 2008-2017.
If you may any questions please contact us: