I am debugging a string variable in Visual Studio using the Text Visualizer. However, it seems that a large part in the middle of the string is missing. What is the reason behind this?
-
Long text was displayed correctly with VS 2015 until Update 1 was installed. The Text Visualizer now does as is explained in the answer below and so fat Microsoft has not said they changed it or why. – David Parvin Dec 03 '15 at 17:53
3 Answers
The Text Visualizer in Visual Studio can only display about 32,700 characters. If your string is longer than that, it will automatically replaces the excess part in the middle of the string with ...
.
I found this out the hard way.
Edit: this seems to have been fixed in Update 2. If you're on Update 1, see Diamond's answer.

- 19,717
- 37
- 107
- 164
-
6Nasty thing, they don't even notify that the text is being trimmed. Spent hours before found that out. Any news on this? Is this confirmed to be a bug? – net_prog Jan 13 '16 at 13:14
-
2One would think they'd truncate the END of the string instead of the middle... would have made it a little more obvious that it was VS and not my web service call causing the problem... – jleach Mar 07 '16 at 15:19
-
So thankful you for this info ... I killed almost whole day because of this issue ... Visual Studio truncated XML document and i saw just 1 node, meanwhile code says that there are 2 nodes ... It was very frustrating. – Disappointed Sep 27 '16 at 14:18
This is an issue that was introduced with Visual Studio 2015 Update 1 as reported here: https://connect.microsoft.com/VisualStudio/feedback/details/2016177/text-visualizer-misses-corrupts-text-in-long-strings.
Microsoft will have a permanent fix for this in the first update after Update 1. In the meantime, use the following workaround: You can set the length at which the Text Visualizer will truncate by adding a registry key. Use the following command to set the length to a larger number (example 250000):
reg add HKCU\Software\Microsoft\VisualStudio\14.0\Debugger /v TextVisualizerStringLimit /t REG_DWORD /d [number]
Alternatively use a previous version of Visual Studio if you have one installed.

- 3,223
- 3
- 28
- 40
-
Not sure when their next update is, but as of 14.0.24720.00 Update 1, this bug still exists. – jleach Mar 07 '16 at 15:04
-
1There is a Release Candidate for Update 2 available from here: https://www.visualstudio.com/en-us/news/vs2015-update2-vs.aspx. It may contain a fix for the issue. Just depends on what else it breaks ... – Ɖiamond ǤeezeƦ Mar 07 '16 at 15:07
There is a solution here.
- Create new project Class Library
- Add new Form MessageForm with TextBox inside, check MaxLength and Multiline properties of TextBox.
- Add .cs file with folowing content:
using System;
using Microsoft.VisualStudio.DebuggerVisualizers;
using System.Windows.Forms;
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(TextVisualizer.DebuggerSide),
typeof(VisualizerObjectSource),
Target = typeof(String),
Description = "My Visualizer")]
namespace TextVisualizer
{
public class DebuggerSide : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
var message = new MessageForm();
((TextBox) message.Controls.Find("textbox1",false)[0]).Text = objectProvider.GetObject().ToString();
message.ShowDialog();
}
}
}
- Build Project
- Locate the DLL that contains the visualizer you have built and
copy the DLL to either of the following locations:
- VisualStudioInstallPath\Common7\Packages\Debugger\Visualizers
- My Documents\VisualStudioVersion\Visualizers
If you want to use a managed visualizer for remote debugging, copy the DLL to the same path on the remote computer. Restart the debugging session. For more information, see How to: Install a Visualizer.

- 65
- 7