Tom Goff's .Net Musings

Tidbits of information regarding .Net, C#, and SQL Server.

COTW: DebuggerNonUserCodeAttribute Class

leave a comment »

The DebuggerNonUserCodeAttribute class allows you to specify classes, structs, constructors, properties, and methods that are not considered “user code”. Using this attribute is the same as applying both DebuggerHiddenAttribute and DebuggerStepThroughAttribute, with one notable exception.

In my previous blog entry about the DebuggerHiddenAttribute, I said

In the tool-tip above, Visual Studio implies that if ‘Just My Code’ was disabled then we would be able to step into class members that have the DebuggerHiddenAttribute. Although, in my tests this was not the case. With ‘Just My Code’ disabled, Visual Studio shows the break point as enabled, but it is never hit and I cannot step into the “hidden” method.

I was referring to the following image, which implies that I should be able to debug items marked with the DebuggerHiddenAttribute:

DebuggerHiddenAttribute 2

I found that if ‘Just My Code’ is disabled, then Visual Studio does ignore DebuggerNonUserCodeAttribute (but not DebuggerHiddenAttribute). Therefore, it’s probably better to use the DebuggerNonUserCodeAttribute in most cases, since it can be disabled by the user.


Written by Tom

November 27, 2007 at 12:29 pm

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: