Search code examples
debuggingwindows-serviceswindbgapplication-verifier

Cannot get exact exception in windbg.exe while attached to Windows service


I am trying to debug the services using Windows Debugging Tools (WinDbg.exe) since my service throws an unhandled exception in production. I followed the instructions of Microsoft and I am able to attach/debug the service and it writes a log with exception information.

But the logs are written without any specific details as below. Am just wondering how to get the exact call stack, exception messages, and assembly references from the exception.

(UTC - 4:00): (179c.7d4): CLR exception - code e0434352 (first chance)    
(UTC - 4:00): (179c.17f4): CLR exception - code e0434352 (first chance)    
(UTC - 4:00): (179c.56c): CLR exception - code e0434352 (first chance)

Server details: Windows Server 2012 R2


Solution

  • WinDbg is a native debugger. It does not know anything about .NET, except the exception name "CLR exception". To get more details about .NET, you need to load an extension which knows about the .NET internals.

    .loadby sos clr
    .loadby sos mscorwks
    

    Once the extension is loaded, there are additional commands for .NET, e.g. analyzing .NET exceptions

    !printexception
    

    or short

    !pe
    

    Another helpful command in your case will be

    !clrstack
    

    to get the .NET stack