Visual Studio 2005 ships with a few handy visualizers for debugging. A visualizer presents a tailored view of an object, which is useful when an object is too complex to fit in a watch window or data tip. Custom visualizers can plug into Visual Studio, see “How To: Write a Visualizer” as a starting point.
I’ve packaged up a couple custom visualizers I’ve used recently into a project: WebVisualizers.zip. The ControlTree visualizer shows the hierarchical relationship of web controls, starting with the visualized control at the top. For instance, if you hover over a this reference inside a web form class, and click the magnifying glass that appears, you’ll see all the controls on a form.
Controls implementing the INamingContainer interface appear in red. This visualizer was helpful in tracking down a misuse of FindControl. The second visualizer in the project will display an HttpCookieCollection in a grid view.
To install the a visualizer you have to build the source code. You can build with Visual Studio, or from the command line “msbuild OdeToCode.WebVisualizers.csproj”, assuming msbuild.exe is in the path. Copy the .dll from underneath the bin directory into “MyDocuments\Visual Studio 2005\Visualizers”. VS.NET will automatically load the assembly when debugging, and inspect the metadata inside to know what types to visualize. Note: custom visualizers won't load for a web site running at less than full trust.
These Visualizers here are relatively simple. Brett Johnson wrote a visualizer for the ASP.NET cache, and a wicked-cool visualizer to render controls.
Comments
Made 2 versions. One for the complete webpage. And one where you it takes in the parent control and it fetches all its children along with values...so had to do type checking on the such controls like "is it a date picker?" or a "drop down list?", etc.
Nice to see someone made a GUI version.
Thanks for releasing the source code, looking into these visualizers has long been on my TODO plate. I went ahead and tinkered with your code and had it so that the control hierarchy displays the properties for each control, and their values. (The reflection adds a bit of a lag for particularly large control hierarchies, though, at least in testing on my computer.)
I uploaded my code changes and posted them on my blog - http://scottonwriting.net/sowblog/posts/4963.aspx
Thanks again.
Great post, i downloaded the the code, copied at specified location, created a file system based web site in visual studio 2005.
Tried but not able to make it. I dont know whats wrong. Also, please tell me what is this indicated to
"Note: custom visualizers won't load for a web site running at less than full trust."
Regards
************** Exception Text **************
Microsoft.VisualStudio.DebuggerVisualizers.DebugViewerShim.RemoteObjectSourceException: Could not load file or assembly 'file:///C:\Documents and Settings\pmoun\My Documents\Visual Studio 2005\Visualizers\OdeToCode.WebVisualizers.dll' or one of its dependencies. Access is denied. ---> System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Documents and Settings\pmoun\My Documents\Visual Studio 2005\Visualizers\OdeToCode.WebVisualizers.dll' or one of its dependencies. Access is denied.
I assume this is because my Visualizers directory lacks an ACL (I've messed with that directory's location on and off a network share since I installed VS2005).
Which users/groups should have access for visualizers to work?
Note that I am attempting to use the Visualizer to debug a strong-named web application. I have compiled the Visualizer to have a strong-name too.
Right, but you have to wait for the page to render (which is too late in some scenarios).