How to watch StringBuilder strings while debugging?
-
How to watch StringBuilder strings while debugging? Hi, I was wondering why I can't make my VS 2008 to watch StringBuilder string-values while debugging? According to this article from Code Magazine: www.code-magazine.com/articleprint.aspx?quickid=0503061&printmode=true , it should be possible, even in VS 2005 (standard) according to figure 3 & 4 in the article. What am I missing? ps: i'm a newbie :) BR Lars
-
How to watch StringBuilder strings while debugging? Hi, I was wondering why I can't make my VS 2008 to watch StringBuilder string-values while debugging? According to this article from Code Magazine: www.code-magazine.com/articleprint.aspx?quickid=0503061&printmode=true , it should be possible, even in VS 2005 (standard) according to figure 3 & 4 in the article. What am I missing? ps: i'm a newbie :) BR Lars
Just highlight over the string you are adding to the SB.. you will see what it is adding. As far as breakpoints or a watch, hmm, I would set something like a conditional watch that dumps the tostring method of the sb, then you will see it being built but you will soon run out of realistate in the debugger for long strings. If that is the case you could create a substring method to display just the last few lines at once...
"Make everything as simple as possible, but not simpler." -- Albert Einstein "It didn't matter to us whether people believed in us. We believed in ourselves. We had the courage to follow our own path." ~~Nvidia's Jen-Hsun Huang
-
Just highlight over the string you are adding to the SB.. you will see what it is adding. As far as breakpoints or a watch, hmm, I would set something like a conditional watch that dumps the tostring method of the sb, then you will see it being built but you will soon run out of realistate in the debugger for long strings. If that is the case you could create a substring method to display just the last few lines at once...
"Make everything as simple as possible, but not simpler." -- Albert Einstein "It didn't matter to us whether people believed in us. We believed in ourselves. We had the courage to follow our own path." ~~Nvidia's Jen-Hsun Huang
Hi TheArchitectmc, thanks for your reply. While debugging, it is interesting to be able to see the actual value of the StringBuilder "string" as it is shown in the article (figure 3), not just what is added. CloseUp of figure 3 here: www.code-magazine.com/ShowLargeArticleImage.aspx?QuickID=0503061&Image=figure3.tif[^] Apparently even in VS 2005, it is possible to do what I ask for, as you can see in the CloseUp picture at "m_StingValue", where the user are offered 3 different visualizer types for better viewing. Since it is advised to use StringBuilder "strings" instead of normal strings for many purposes, I would say that being able to watch these while debugging, should be a mandatory option "out of the box", without the need for adding code. I hope someone can help :) BR Lars
-
How to watch StringBuilder strings while debugging? Hi, I was wondering why I can't make my VS 2008 to watch StringBuilder string-values while debugging? According to this article from Code Magazine: www.code-magazine.com/articleprint.aspx?quickid=0503061&printmode=true , it should be possible, even in VS 2005 (standard) according to figure 3 & 4 in the article. What am I missing? ps: i'm a newbie :) BR Lars
Works fine for me in VS 2008.
Need custom software developed? I do custom programming based primarily on MS tools with an emphasis on C# development and consulting. A man said to the universe: "Sir I exist!" "However," replied the universe, "The fact has not created in me A sense of obligation." --Stephen Crane
-
Hi TheArchitectmc, thanks for your reply. While debugging, it is interesting to be able to see the actual value of the StringBuilder "string" as it is shown in the article (figure 3), not just what is added. CloseUp of figure 3 here: www.code-magazine.com/ShowLargeArticleImage.aspx?QuickID=0503061&Image=figure3.tif[^] Apparently even in VS 2005, it is possible to do what I ask for, as you can see in the CloseUp picture at "m_StingValue", where the user are offered 3 different visualizer types for better viewing. Since it is advised to use StringBuilder "strings" instead of normal strings for many purposes, I would say that being able to watch these while debugging, should be a mandatory option "out of the box", without the need for adding code. I hope someone can help :) BR Lars
LarsXYZ wrote:
Apparently even in VS 2005, it is possible to do what I ask for, as you can see in the CloseUp picture at "m_StingValue", where the user are offered 3 different visualizer types for better viewing.
Hmm, Visual Studio has what are called 'Visualizers' there is a special folder you place them in on your installation of VS. I think that is what you are seeing. Here is a link for one some one created:\ Platinum Bay - StringBuilder Visualizer[^] Hope this is what you are looking for. But you could also build your own custom stringbuilder visualizer if you wanted, I can see the whole thing in my head, so I have never needed one, I do use other visualizers for LINQ and Lambda Expressions... ~TheArch :cool:
"Make everything as simple as possible, but not simpler." -- Albert Einstein "It didn't matter to us whether people believed in us. We believed in ourselves. We had the courage to follow our own path." ~~Nvidia's Jen-Hsun Huang
-
LarsXYZ wrote:
Apparently even in VS 2005, it is possible to do what I ask for, as you can see in the CloseUp picture at "m_StingValue", where the user are offered 3 different visualizer types for better viewing.
Hmm, Visual Studio has what are called 'Visualizers' there is a special folder you place them in on your installation of VS. I think that is what you are seeing. Here is a link for one some one created:\ Platinum Bay - StringBuilder Visualizer[^] Hope this is what you are looking for. But you could also build your own custom stringbuilder visualizer if you wanted, I can see the whole thing in my head, so I have never needed one, I do use other visualizers for LINQ and Lambda Expressions... ~TheArch :cool:
"Make everything as simple as possible, but not simpler." -- Albert Einstein "It didn't matter to us whether people believed in us. We believed in ourselves. We had the courage to follow our own path." ~~Nvidia's Jen-Hsun Huang
Hi TheArchitectmc, thanks again for your reply. I tried the StringBuilder visualizer from Platinum Bay & copied the dll to the visualizers folder, like: c:\MVS_2008\Common7\Packages\Debugger\Visualizers\StringBuilderVisualizer.dll In a project I created a reference to the StringBuilderVisualizer.dll and wrote the Imports statement (Imports StringBuilderVisualizer) in the start of my code. That didn't work & the new StringBuilderVisualizer was stated as an "unused" reference?? How can that be? I must say that i'm quite surprised if the feature I'm asking for, isn't in the VS 2008 standard package Basically, the only info I get when watching StringBuilder "strings" is: Capacity Chars (with a standard message: In order to evaluate...) Length MaxCapacity Thats it! The most important part: The actual string-value, are missing :( BR Lars
-
Hi TheArchitectmc, thanks again for your reply. I tried the StringBuilder visualizer from Platinum Bay & copied the dll to the visualizers folder, like: c:\MVS_2008\Common7\Packages\Debugger\Visualizers\StringBuilderVisualizer.dll In a project I created a reference to the StringBuilderVisualizer.dll and wrote the Imports statement (Imports StringBuilderVisualizer) in the start of my code. That didn't work & the new StringBuilderVisualizer was stated as an "unused" reference?? How can that be? I must say that i'm quite surprised if the feature I'm asking for, isn't in the VS 2008 standard package Basically, the only info I get when watching StringBuilder "strings" is: Capacity Chars (with a standard message: In order to evaluate...) Length MaxCapacity Thats it! The most important part: The actual string-value, are missing :( BR Lars
LarsXYZ wrote:
I tried the StringBuilder visualizer from Platinum Bay & copied the dll to the visualizers folder, like: c:\MVS_2008\Common7\Packages\Debugger\Visualizers\StringBuilderVisualizer.dll
This looks correct...
LarsXYZ wrote:
In a project I created a reference to the StringBuilderVisualizer.dll and wrote the Imports statement (Imports StringBuilderVisualizer) in the start of my code. That didn't work & the new StringBuilderVisualizer was stated as an "unused" reference?? How can that be? I must say that i'm quite surprised if the feature I'm asking for, isn't in the VS 2008 standard package
I don't think you need a hard refrence to the assembly, Visual Studio will pick up the visualizer automatically. Or should at least. With some visualizers there are extra steps requited to registed them with Visual Studio. Visual Studio is built to be extensible. It's not ment to be a complete solution for every vertical or horizontal market that tried to use it. Microsoft avoided this on purpose. It would make sence that StringBuilder should be something you should be able to inspect, however, due to the nature of how it is used in various Vertical and Horizontal markets it makes sence that they left the implimentation to the development team to design a custom visualizer for ther spicific needs since a hugh string can have may complicated types of data, it could be XMAL, XML, HTML, searialzed String objects, etc. So allowing the development team to creat and extend this feature makes perfect sence. As I have said when I use a StringBuilder I view it as mearly a container, I know exactly what is in the container and StringBuilder never does anything but the operations exposed, so if you are doing advanced things like string replacments etc, it could be useful to have a visualizer, however I sdon't beleive this is a good design practice, I just put exactly waht I want in it, if there is any preprocessing on the data that goes in I do it before and leave the contents completly as they are until such a time as I 'dump' the contents of the StringBuilder to a stream etc. Take a look at these two MSDN articles on visualizers: How to: Write a Visualizer[^]
-
LarsXYZ wrote:
Apparently even in VS 2005, it is possible to do what I ask for, as you can see in the CloseUp picture at "m_StingValue", where the user are offered 3 different visualizer types for better viewing.
Hmm, Visual Studio has what are called 'Visualizers' there is a special folder you place them in on your installation of VS. I think that is what you are seeing. Here is a link for one some one created:\ Platinum Bay - StringBuilder Visualizer[^] Hope this is what you are looking for. But you could also build your own custom stringbuilder visualizer if you wanted, I can see the whole thing in my head, so I have never needed one, I do use other visualizers for LINQ and Lambda Expressions... ~TheArch :cool:
"Make everything as simple as possible, but not simpler." -- Albert Einstein "It didn't matter to us whether people believed in us. We believed in ourselves. We had the courage to follow our own path." ~~Nvidia's Jen-Hsun Huang
Thanks, works fine!
-
LarsXYZ wrote:
I tried the StringBuilder visualizer from Platinum Bay & copied the dll to the visualizers folder, like: c:\MVS_2008\Common7\Packages\Debugger\Visualizers\StringBuilderVisualizer.dll
This looks correct...
LarsXYZ wrote:
In a project I created a reference to the StringBuilderVisualizer.dll and wrote the Imports statement (Imports StringBuilderVisualizer) in the start of my code. That didn't work & the new StringBuilderVisualizer was stated as an "unused" reference?? How can that be? I must say that i'm quite surprised if the feature I'm asking for, isn't in the VS 2008 standard package
I don't think you need a hard refrence to the assembly, Visual Studio will pick up the visualizer automatically. Or should at least. With some visualizers there are extra steps requited to registed them with Visual Studio. Visual Studio is built to be extensible. It's not ment to be a complete solution for every vertical or horizontal market that tried to use it. Microsoft avoided this on purpose. It would make sence that StringBuilder should be something you should be able to inspect, however, due to the nature of how it is used in various Vertical and Horizontal markets it makes sence that they left the implimentation to the development team to design a custom visualizer for ther spicific needs since a hugh string can have may complicated types of data, it could be XMAL, XML, HTML, searialzed String objects, etc. So allowing the development team to creat and extend this feature makes perfect sence. As I have said when I use a StringBuilder I view it as mearly a container, I know exactly what is in the container and StringBuilder never does anything but the operations exposed, so if you are doing advanced things like string replacments etc, it could be useful to have a visualizer, however I sdon't beleive this is a good design practice, I just put exactly waht I want in it, if there is any preprocessing on the data that goes in I do it before and leave the contents completly as they are until such a time as I 'dump' the contents of the StringBuilder to a stream etc. Take a look at these two MSDN articles on visualizers: How to: Write a Visualizer[^]
-
Hi TheArchitectmc Thanks a lot for your replies :) Finally I succeeded with the StringBuilderVisualizer, which loads automatically. It works fine with a listbox, I just had to discover how to activate it :) BR Lars
LarsXYZ wrote:
Finally I succeeded with the StringBuilderVisualizer, which loads automatically. It works fine with a listbox, I just had to discover how to activate it
That is great news I had the same sort of problem when I started using visualisers. Next since you are starting out I would suggest you get to better know the full power of Visual Studio and download the Visual Studio SDK and look at the examples. Also take a look at DSL's they provide a way to design and develop an architecture specific to a horizontal or vertical market and much more. Also look into T4 it's a powerful code generating template that you can embed .NET in and reuse in many other projects and create specific types of start-up projects. :-\ ~TheArch
"Make everything as simple as possible, but not simpler." -- Albert Einstein "It didn't matter to us whether people believed in us. We believed in ourselves. We had the courage to follow our own path." ~~Nvidia's Jen-Hsun Huang