Discussion:
Problem with Debug.Assert
Brady Kelly
2008-05-28 20:15:46 UTC
Permalink
When I run the following code in the IDE, under the Debug configuration,
when I choose Retry on the dialogue presented by the assert, I get a message
that no source code is available for the current location. Can anyone
enlighten me as to why VS2008 cannot see the obviously available code at
that location?

string ns = null;
// -- Missing code or operation to initialise ns should be here.

// I only want to stop processing here when debugging.
Debug.Assert(ns != null, "Whoops! ns is null");
if (ns == null)
{
Trace.WriteLine("Cannot print ns because ns is null");
}
else
{
Console.WriteLine("ns = {0}", ns);
}




===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
John Brett
2008-05-29 06:47:30 UTC
Permalink
Post by Brady Kelly
When I run the following code in the IDE, under the Debug configuration,
when I choose Retry on the dialogue presented by the assert, I get a message
that no source code is available for the current location. Can anyone
enlighten me as to why VS2008 cannot see the obviously available code at
that location?
Have you enabled address-level debugging but not "Show disassembly if
source not available"? That's in Tools/Options/Debugging/General in
VS2005

I've also seen this when the available source doesn't match the
executable, and I've just plain had the IDE throw a strop and fail to
load the symbols at all. A reboot or rebuild has always fixed that for
me in the past.

John

===================================
This list is hosted by DevelopMentor® http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Brady Kelly
2008-05-29 09:26:02 UTC
Permalink
Post by Brady Kelly
Post by Brady Kelly
When I run the following code in the IDE, under the Debug
configuration,
Post by Brady Kelly
when I choose Retry on the dialogue presented by the assert, I get a
message
Post by Brady Kelly
that no source code is available for the current location. Can
anyone
Post by Brady Kelly
enlighten me as to why VS2008 cannot see the obviously available code
at
Post by Brady Kelly
that location?
Have you enabled address-level debugging but not "Show disassembly if
source not available"? That's in Tools/Options/Debugging/General in
VS2005
I've also seen this when the available source doesn't match the
executable, and I've just plain had the IDE throw a strop and fail to
load the symbols at all. A reboot or rebuild has always fixed that for
me in the past.
John
John, in VS 2008, with address level debugging disabled, I get a no source
code available, period, error message. With 'Show disassembly.." enabled, I
go straight to the disassembly, without it, I get the same source code
message, but with an option to view disassembly.

I find that enabling "Just my code (Managed only)" suppresses the warning
about source code availability.

Interesting, in all cases, one 'single-step' enters a break-point on the
assert line, regardless of what is enabled and what not.

===================================
This list is hosted by DevelopMentor� http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com
Loading...