ProblemSolving - KirillOsenkov/kirillosenkov.github.io GitHub Wiki

A .NET Developer's Problem-Solving Toolbelt

I find that a lot of problems in the .NET world can be investigated and solved using a quite limited but complementary set of tools. Knowing what tools to apply in which situation will make you a great problem solver and a go-to person on your team.

Debugging

Starting a new .exe under debugger

When you need to attach a debugger to the very beginning of a process execution, you can open the .exe file in Visual Studio using File -> Open Project. It will open the .exe as a "project", and in that project's properties you can configure the command line arguments, working directory, etc.

image

Automatically collecting .dmp dumps for crashing processes

Run this .reg file:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\LocalDumps]
"DumpFolder"="C:\CrashDumps"
"DumpCount"=dword:00000010
"DumpType"=dword:00000002

It will ensure that for every crashing application on your system an automatic full dump is saved in the C:\CrashDumps folder. It will preserve 16 (0x10) latest dumps. DumpType 0x2 means full dump. More info: https://msdn.microsoft.com/en-us/library/windows/desktop/bb787181(v=vs.85).aspx

Automatically attach to child processes started by the debuggee

Use this Visual Studio extension: https://marketplace.visualstudio.com/items?itemName=GreggMiskelly.MicrosoftChildProcessDebuggingPowerTool If you enable it and debug using mixed mode (Managed + Native), it will automatically attach to all child processes started by the parent debuggee process.

Visual Studio supports attaching to more than one process at a time. You can switch the "active" process in the Debug -> Windows -> Processes tool window.

Investigating build issues

Investigating assembly versions, assembly loading and runtime resolution