Often exceptions are thrown and caught and you don't see them. You probably know how to debug this in Visual Studio, so let me show you how to do it in cdb.
Sample Code:
class ProgramOutput of the application:
{
static void Main(string[] args)
{
foreach (var x in Enumerable.Range(0,2000))
{
Thread.Sleep(TimeSpan.FromSeconds(1));
Console.WriteLine("Hello World");
ThrowAndCatchException();
}
}
private static void ThrowAndCatchException()
{
try
{
throw new NotImplementedException();
}
catch(Exception)
{
}
}
}
Hello WorldNothing about an exception, but you're sure it's happening behind the covers -- fire up cdb:
Hello World
Hello World
C:\Program Files\Debugging Tools for Windows (x64)>cdb -pn consoleapplication3.exeContinue debugging:
<SNIP>
ModLoad: 000007fe`f7e90000 000007fe`f7eb4000 C:\Windows\Microsoft.NET\Framework64\v4.0.20506\culture.dll
(ff8.17a8): Break instruction exception - code 80000003 (first chance)
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\SYSTEM32\ntdll.dll -
ntdll!DbgBreakPoint:
00000000`77b7d7b0 cc int 3
0:004> gExceptions - lots of them:
(ff8.16dc): CLR exception - code e0434352 (first chance)Break on CLR exceptions:
(ff8.16dc): CLR exception - code e0434352 (first chance)
(ff8.16dc): CLR exception - code e0434352 (first chance)
(ff8.16dc): CLR exception - code e0434352 (first chance)
(ff8.16dc): CLR exception - code e0434352 (first chance)
(ff8.16dc): CLR exception - code e0434352 (first chance)
(ff8.1860): Break instruction exception - code 80000003 (first chance)
0:004> sxe clrLoad sos ( in .Net 2/3 use use !loadby sos mscorwks):
0:004> g
(ff8.16dc): CLR exception - code e0434352 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\system32\KERNELBASE.dll -
KERNELBASE!RaiseException+0x3d:
000007fe`fdb8bb5d 4881c4c8000000 add rsp,0C8h
0:000> !loadby sos clrView Stack:
0:000> !CLRStackView Exception:
PDB symbol for clr.dll not loaded
OS Thread Id: 0x16dc (0)
Child SP IP Call Site
000000000096e6a8 000007fefdb8bb5d [HelperMethodFrame: 000000000096e6a8]
000000000096e7c0 000007ff00170360 ConsoleApplication3.Program.ThrowAndCatchException()
000000000096e810 000007ff001701fb ConsoleApplication3.Program.Main(System.String[])
000000000096ec90 000007feef474ca4 [GCFrame: 000000000096ec90]
0:000> !PrintExceptionPretty neat - eh?
Exception object: 0000000002c88c18
Exception type: System.NotImplementedException
Message: The method or operation is not implemented.
InnerException: <none>
StackTrace (generated):
<none>
StackTraceString: <none>
HResult: 80004001
0:000>
Sweet, thanks!!!!
ReplyDeleteThank you for this nice tips. It helped me solve a very frustrating problem when trying to deploy an C# app :)
ReplyDeleteAnd more importantly I'm now able to debug more effectively in the future.
couldnt understand anything .... pls tell me how to solve this problem ....?
ReplyDeletewhile am shuting down the windows its showing me like
ReplyDelete"The exception unknown software exception (0xe0434352)occurred in the application at location 0x850f89cc"
i doesnt know what to do now please help me...!!
Same situation . Can't someone speak in lay men's terms speaking slowly and all steps needed.
ReplyDeleteRepeat of previous comment. How do I fix this "error". It affects Kaspersky Internet Security.
ReplyDeleteThis totally just helped me solve my problem.
ReplyDeleteThanks so much!
The Constitution only gives people the right to pursue happiness. You have to catch it yourself. See the link below for more info.
ReplyDelete#catched
www.ufgop.org
If you are not willing to learn, No one can help you. If you are determined to learn, No one can stop you.
ReplyDeleteimarksweb.net