Reputation: 20705
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?
Upvotes: 16
Views: 4519
Reputation: 20705
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.
Upvotes: 20
Reputation: 3331
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.
Upvotes: 4
Reputation: 65
There is a solution here.
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();
}
}
}
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.
Upvotes: 2