Thursday, July 29, 2010

Visual Studio 2010 Trace Options for WPF 4.0

Visual Studio is one of the most popular and interesting IDE that Microsoft has build to enhance the productivity of Developers. The Visual Studio IDE is not created just to help the developers, but if you see the survey of how and where the Visual Studio is been used, you would be surprised to see that how much it is used by even non-technical persons.

Microsoft always makes me happy with certain things that I might have always wanted. Just today, I saw the same. Visual Studio 2010 now comes with inbuilt Tracer for WPF applications, to trace the internal calls to the Binding DataElements to the debug output window. There are options to turn on trace settings especially for WPF applications to trace WPF animations, Bindings etc which were more or less abstract to us. So if you put a tracer on to these settings, it will automatically log steps that it does while doing WPF steps. Lets look into how you could do this :

  1. Open your WPF Application.
  2. Go to Tools -> Options.


  3. In the Left side treeView, choose Debugging - > Output window
  4. Now, you can see WPF Trace Settings Section. 
This section lists all the abstract WPF steps, which every developer would love to see and those which have very less or even no trace option from code. In the above figure you can see we can also enable tracer to certain levels like, Critical, Error, Warning, Information, Verbose, Activity, All... each of them will trace to the extent we provide.



Say I put tracer on for a DataBinding statement and run my application with XML DataBinding steps, we see :

'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Windows.Forms\v4.0_4.0.0.0__b77a5c561934e089\System.Windows.Forms.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Drawing\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.HostingProcess.Utilities.Sync\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.HostingProcess.Utilities.Sync.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualStudio.Debugger.Runtime\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualStudio.Debugger.Runtime.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Documents and Settings\Abhishek\my documents\visual studio 2010\Projects\XMLBinding\XMLBinding\bin\Debug\XMLBinding.vshost.exe', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xml.Linq\v4.0_4.0.0.0__b77a5c561934e089\System.Xml.Linq.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Data.DataSetExtensions\v4.0_4.0.0.0__b77a5c561934e089\System.Data.DataSetExtensions.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Xaml\v4.0_4.0.0.0__b77a5c561934e089\System.Xaml.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\WindowsBase\v4.0_4.0.0.0__31bf3856ad364e35\WindowsBase.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_32\PresentationCore\v4.0_4.0.0.0__31bf3856ad364e35\PresentationCore.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread '<No Name>' (0x11ac) has exited with code 0 (0x0).
The thread 'vshost.LoadReference' (0x1108) has exited with code 0 (0x0).
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\Documents and Settings\Abhishek\my documents\visual studio 2010\Projects\XMLBinding\XMLBinding\bin\Debug\XMLBinding.exe', Symbols loaded.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Step into: Stepping over non-user code 'XMLBinding.App.App'
Step into: Stepping over non-user code 'XMLBinding.App.InitializeComponent'
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\PresentationFramework.Luna\v4.0_4.0.0.0__31bf3856ad364e35\PresentationFramework.Luna.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'XMLBinding.vshost.exe' (Managed (v4.0.30319)): Loaded 'C:\WINDOWS\Microsoft.Net\assembly\GAC_MSIL\System.Numerics\v4.0_4.0.0.0__b77a5c561934e089\System.Numerics.dll', Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
The thread '<No Name>' (0xcf4) has exited with code 0 (0x0).
The thread '<No Name>' (0x10d4) has exited with code 0 (0x0).
The thread '<No Name>' (0xaf0) has exited with code 0 (0x0).
The thread 'vshost.RunParkingWindow' (0xa6c) has exited with code 0 (0x0).
The thread '<No Name>' (0x107c) has exited with code 0 (0x0).
The program '[4300] XMLBinding.vshost.exe: Managed (v4.0.30319)' has exited with code 0 (0x0).

Thus you can see the  Tracer steps in your Output window as above.

Note : You should not keep the Tracer to run all the time and make this as your default settings for Visual Studio. As Tracer is a special task for the debugger, it will make the Visual Studio run a bit slow than normal, and hence by turning on the Trace functionality will eventually decrease the performance a bit. So use it whenever you require it.

Thank you for reading.

No comments:

Post a Comment

Please make sure that the question you ask is somehow related to the post you choose. Otherwise you post your general question in Forum section.

Author's new book

Abhishek authored one of the best selling book of .NET. It covers ASP.NET, WPF, Windows 8, Threading, Memory Management, Internals, Visual Studio, HTML5, JQuery and many more...
Grab it now !!!