Visual Studio 2010 removed the ability to “Visualize” a StringBuilder type unless you append the .ToString() method to the StringBuilder object you are debugging.
Seth Richards posted an article on this topic and, in addition, wrote a custom Visualizer (download Seth’s VS2010 solution here) to compensate for Visual Studio 2010′s lack of support for the StringBuilder visualization. Thanks, Seth!
Seth’s solution works fine and good in the sense that it does display a string visualizer for a StringBuilder type without the need to manually specifying the .ToString() method. However, it doesn’t support an HTML Visualizer – i.e. if the content of the StringBuilder contains HTML text, Seth’s StringBuilder Visualizer will display the raw HTML instead of rendering the HTML.
I’ve taken the liberty of updating Seth’s custom StringBuilder Visualizer to render HTML that may exist in the StringBuilder object. Working off of Seth’s code, I added a new Windows Form which contains a Web Browser control. Then I set the Web Browser control’s DocumentText property with the content of the StringBuilder object that is gettin’ debugged. Download the StringBuilder HTML Visualizer Solution here (this solution was originated by Seth Richards, then updated by me).
Note: Due to restrictions by my host, you will need to rename the .xls extension to .zip.
- Download the solution
- Rename the extension “.xls” to “.zip”
- Unzip the file
- Build the solution
- Copy the compiled dll to your VS2010 Visualizer directory – i.e. ..\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers
- Improve the solution and share