ENTERPRISE

NET Debugging : Visual Studio (part 1) - SOS Integration

11/19/2013 8:17:58 PM

Visual Studio is an extremely popular integrated developer environment among developers. The power of this IDE coupled with its ease of use makes it the environment of choice for .NET developers today. As part of the Visual Studio integrated experience comes a highly sophisticated debugger that can be used to perform troubleshooting on a myriad of different problems, such as using source-level debugging, script debugging, and SQL debugging. The one area where Visual Studio debugging has lacked functionality is in production-level debugging where we either need to work with post mortem dump files or have access to the internals of the CLR (such as the SOS commands). Fortunately, the Visual Studio team recognized and addressed the latter part of the problem by making Visual Studio compatible with the SOS debugger extension.

1. SOS Integration

To illustrate how the SOS debugger extension can be integrated into Visual Studio, start by creating a simple C# project (command-line application will suffice). After the project has been created, set a breakpoint on the first line of code and start debugging by pressing F5. Figure 1 shows the debugger after the breakpoint has been hit.

Figure 1. Breakpoint hit in Visual Studio

The next step in the SOS integration process is to bring up the intermediate window. The intermediate window is used to execute various commands (such as variable assignments, expression evaluations, etc.) during a debugging session. Figure 2 shows how to enable the Immediate Window.

Figure 2. Enabling the Immediate Window

After the Immediate Window has been enabled, you can begin entering debugging commands. One of the commands available at our disposal is the load command, which can be used to load the SOS debugger extension. Figure 3 illustrates the result of executing the load command.

Figure 3. Using the load command to load the SOS debugger extension

The net result of using the load command is that Visual Studio fails by stating that unmanaged debugging support must be enabled for the project. Figure 4 illustrates the process of enabling unmanaged debugging support.

Figure 4. Enabling unmanaged debugging support

Start by right-clicking the project in Solution Explorer followed by selecting the Properties context menu item, which brings up the properties page on the right side. In the properties page, select the Debug tab and check the Enable Unmanaged Code Debugging checkbox.

After unmanaged code debugging has been enabled, you can restart the debugging session, issue the load SOS command, and start using the SOS debugger extension commands in the Immediate Window (see Figure 5).

Figure 5. Using the SOS debugger extension

In Figure 5, we used two SOS commands (EEVersion and DumpHeap) to illustrate what the output looks like in the Immediate Window.

Combining the power and ease of Visual Studio with the in-depth CLR knowledge of SOS creates a single, integrated experience for complex debugging scenarios.

Other  
  •  System Center Configuration Manager 2007 : Creating Packages (part 3) - About Packages, Programs, Collections, Distribution Points, and Advertisements
  •  System Center Configuration Manager 2007 : Creating Packages (part 2) - Comparing GPO-based Software Distribution to ConfigMgr Software Distribution
  •  System Center Configuration Manager 2007 : Creating Packages (part 1)
  •  Microsoft Dynamic AX 2009 : Configuration and Security - Security Framework (part 3) - Security Coding
  •  Microsoft Dynamic AX 2009 : Configuration and Security - Security Framework (part 2) - Applying Security
  •  Microsoft Dynamic AX 2009 : Configuration and Security - Security Framework (part 1)
  •  Microsoft Dynamic AX 2009 : Configuration and Security - Licensing and Configuration
  •  Microsoft Dynamic AX 2009 : Configuration and Security - IntelliMorph
  •  Microsoft Dynamic AX 2009 : Reflection APIs (part 3) - Treenodes API
  •  Microsoft Dynamic AX 2009 : Reflection APIs (part 2) - Dictionary API
  •  
    Video
    Video tutorials
    - How To Install Windows 8

    - How To Install Windows Server 2012

    - How To Install Windows Server 2012 On VirtualBox

    - How To Disable Windows 8 Metro UI

    - How To Install Windows Store Apps From Windows 8 Classic Desktop

    - How To Disable Windows Update in Windows 8

    - How To Disable Windows 8 Metro UI

    - How To Add Widgets To Windows 8 Lock Screen

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010
    programming4us programming4us
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    Popular Tags
    Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Exchange Server Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe Photoshop CorelDRAW X5 CorelDraw 10 windows Phone 7 windows Phone 8 Iphone