In this post I’ll show you how to configure your Visual Studio 2010 to step into the source code of .NET Framework 4.0 in 9 easy steps.

  1. Download the 167Mb installer that contains the logic and data required to install Reference Source, .Net 4.0. On the download page table, its named “.Net”, Version: 4.
  2. Execute the installer “Net_4.msi” that you have downloaded in the previous step.
  3. Install it onto a path of your choice. Example “C:\Development\Framework 4 Source
  4. Launch Visual Studio 2010. From the Tools menu, choose Options and open the Debugging node.
  5. Select General, then do the following:
    • Uncheck “Enable Just My Code (Managed only)”
    • Check “Enable source server support”
    • Uncheck “Require source files to exactly match the original version”
    • Optional: Uncheck “Step over properties and operators (Managed only)”
  6. Select Symbols under Debugging.
  7. In the Symbol File Locations box, add the downloaded symbols location: “C:\Development\Framework 4 Source\Symbols
  8. Enter in text box under ‘Cache symbols in this directory’: “C:\Development\Framework 4 Source\Symbols\Cache
  9. That’s it, you can now Step Into .NET source code. Happy sessions!

Technorati Tags: , ,

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

This reference tutorial will help you grasp the power of WinDebug debugging tool and quickly start using it in your daily development tasks. So, before we start, let me explain what WinDbg is.

WinDbg is a multipurpose debugger for Microsoft Windows, distributed on the web by Microsoft. It can be used to debug user mode applications, drivers, and the operating system itself in kernel mode. It is a GUI application, but has little in common with the more well-known, but less powerful, Visual Studio Debugger. WinDbg can be used for debugging kernel-mode memory dumps, created after what is commonly called the Blue Screen of Death which occurs when a bug check is issued. It can also be used to debug user-mode crash dumps. This is known as Post-mortem debugging.

WinDbg also has the ability to automatically load debugging symbol files (e.g., PDB files – Program DataBase file with debug information) from a server by matching various criteria (e.g., timestamp, CRC, single or multiprocessor version). This is a very helpful and time saving alternative to creating a symbol tree for a debugging target environment. If a private symbol server is configured, the symbols can be correlated with the source code for the binary. This eases the burden of debugging problems that have various versions of binaries installed on the debugging target by eliminating the need for finding and installing specific symbols version on the debug host. Microsoft has a public symbol server that has most of the public symbols for Windows 2000 and later versions of Windows (including service packs).

I’ve used WinDbg mostly in .NET applications, and that’s what I’ll be sharing this time around. To keep things simple and fast, because if you need WinDbg you are probably dealing with some memory issues and time is precious, I’ll put put it in steps:

1) You can start by downloading debugging tools from the Microsoft Windows SDK for Windows 7 and .NET Framework 4. You may also opt to download the ISO version. Take into consideration the target instruction set, either x84 or x64, depending on your application requirements.

2) Run WinDbg.exe executable. Search for WinDbg in "C:\Program Files (x86)\Debugging Tools for Windows (x86)" or “…WinDDK\7600.16385.1\Debuggers\windbg.exe” if you have the Windows Driver Development Kit.

3) Load mscorlib by writing:

        > sxe ld:mscorlib
        > g
       
        NOTE: Press enter after each line. "g" continues debuger execution.

4) Load the SOS Debugging Extension (SOS.dll). This allows debugging of managed programs in the WinDbg.exe debugger and in Visual Studio by providing information about the internal common language runtime (CLR) environment. First command in example loads SOS for debugging framework 2.0. The second is used for Framework 4.0.

        > .loadby sos mscorwks
        > .loadby sos clr (Framework 4.0)
        > g

5) Quick usage scenario #1: View memory consumption for all objects of a given type

        > !DumpHeap -type MyAppRootNamespace.ViewModels.ClientProfileViewModel

6) Quick usage scenario #2: View the managed call stack

        > !CLRStack

7) Quick usage scenario #3: View which object(s) are holding a reference to a specified address

        > !gcroot 29682dc0

 

Here’s a little script you can use to detect Framework 4 and load it in WinDbg.
   
    > !for_each_module .if(($sicmp( "@#ModuleName" , "mscorwks") = 0) ) {bp mscorwks!WKS::GCHeap::SuspendEE ".if (dwo(mscorwks!WKS::GCHeap::GcCondemnedGeneration)==2) {.echo start of gen 2}"} .elsif ($sicmp( "@#ModuleName" , "clr") = 0) {bp clr!WKS::GCHeap::SuspendEE ".if (dwo(clr!WKS::GCHeap::GcCondemnedGeneration)==2) {.echo start of gen 2}"}

 

Also, a full list of WinDbg commands, organized by category: http://windbg.info/doc/1-common-cmds.html.

And a PDF for you to print and keep it around your workspace.

 

Happy sessions.

Technorati Tags: , ,

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Visual Studio 2010 Beta 1 now public

0

It’s been a while since I posted here, and shameless as it might seem I just moved to my new appartment and it’s been a busy month.

Trying to redeem my self, It’s time for another great announcement: On Monday, Microsoft released Visual Studio/Team System 2010 and .NET 4.0 Beta 1 for those who are MSDN subscribers. Well today it is time for everyone else to have a piece of the cake. Counting from yesterday, the download is publically available to anyone who wants to download it. I have to say that this is indeed a treat. The new features are simply awesome, and I’m yet to see the end of them. Will this be the end of those Silent Crashes?

 Give it a test drive here.

Technorati Tags:

Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Note: Silverlight, C#, in fact any .NET web development projects is best used with windows hosting than Linux based hosting.