Groups | Blog | Home
all groups > visual studio .net debugging > july 2006 >

visual studio .net debugging : DebuggerDisplay attribute Target property not working



Abhishek Ghuwalewala
7/26/2006 10:37:37 AM
When I use the DebuggerDisplay attribute at the assembly level and specify
the Target property, the VS2005 debugger does not display the specified
debug string. For example, I have the following line of code compiled into
my assembly in AssemblyInfo.cs:

[assembly: DebuggerDisplay(@"\{Example String: {ExampleString}}", Target =
typeof(UsingDebuggerDisplayAttribute.Example))]

I have the following class defined:

namespace UsingDebuggerDisplayAttribute
{

//[DebuggerDisplay(@"\{Example String: {ExampleString}}")]
public class Example
{
public string ExampleString = "A String";
}

}

If I look at this class in the VS2005 debugger, I do not get the specified
debug string. But, if I comment out the line of code above the Example class
(where the Target is not specified and the attribute is not assembly level),
then I get the specified debug string.

jetan NO[at]SPAM online.microsoft.com (
7/27/2006 4:11:07 AM
Hi Abhishek,

Thanks for your post!

Yes, I can reproduce this behavior. After performed some research, I found
that assembly level DebuggerDisplay attribute should be placed in %user
profile%\My Documents\Visual Studio 2005\Visualizers\autoexp.cs file. The
VS2005 debugger will find and load autoexp.dll in this folder. This is
documented in our VC# program manager Anson Horton's Blog below:
"Tip#25: Customizing the framework types display with DebuggerDisplay"
http://blogs.msdn.com/ansonh/

Below is the my test steps that works:
1. I create a C# project in G:\Program\winform\2006\7-27\DebugDisplayTest\
folder, code is listed below:

using System;
using System.Collections.Generic;
using System.Text;

namespace UsingDebuggerDisplayAttribute
{
public class Example
{
public string ExampleString = "A String";

static void Main(string[] args)
{
Example obj = new Example();
obj.ExampleString = "abc";
}
}
}

2. I edit %user profile%\My Documents\Visual Studio
2005\Visualizers\autoexp.cs file and add the following attribute:
[assembly: DebuggerDisplay(@"\{Example String value is: {ExampleString}}",
Target = typeof(UsingDebuggerDisplayAttribute.Example))]

3. I use csc.exe from .Net Framework2.0 to compile it:
D:\Microsoft Visual Studio 8\SDK\v2.0>csc /t:library
/reference:G:\Program\winform\2006\7-27\DebugDisplayTest\bin\Debug\DebugDisp
layTest.exe "%user profile%\My Documents\Visual Studio
2005\Visualizers\autoexp.cs"

4. I find the new compiled autoexp.dll in folder "D:\Microsoft Visual
Studio 8\SDK\v2.0", copy it and overwrite the old one in %user profile%\My
Documents\Visual Studio 2005\Visualizers\ folder.(Note: take care of and
backup the old one)

5. When I press F5 and hit the breakpoint in obj.ExampleString = "abc";
line, the watch window shows the customized value correct.

Hope this helps!

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Abhishek Ghuwalewala
8/3/2006 2:11:13 PM

[quoted text, click to view]
Thank you. This has solved the problem I was having. By the way, what was
the idea behind changing the debugger display mechanism completely in VS2005
such that there is no backward compatibility with VS2003 (appending to
mcee_cs.dat)?

Abhishek

[quoted text, click to view]
jetan NO[at]SPAM online.microsoft.com (
8/4/2006 12:00:00 AM
Hi Abhishek,

Based on my internal search, mcee_cs.dat is the file name for C# EE, so I
think this file is used to store the execution information. However, the
design idea information is out of my hand and is hard for me to guess.
Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
Abhishek Ghuwalewala
8/8/2006 11:03:42 AM

[quoted text, click to view]
Thanks. My issue is resolved.

Abhishek


[quoted text, click to view]
AddThis Social Bookmark Button