30
votes

I need to debug a 32-bit managed application using WinDbg, however WinDbg stubbornly refuses to load the SOS.dll extension. After many Internet searches and things tried I'm stumped. I have experience debugging unmanaged code with WinDbg but this is my first attempt with managed.

When I direct WinDbg to load the default SOS.dll it gives this error:

sxe ld clr                <- I wait until the clr has loaded
.loadby sos clr

The call to LoadLibrary(C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos) failed,     Win32 error 0n193
    "%1 is not a valid Win32 application."
Please check your debugger configuration and/or network access.

And if I instead attempt to specify the SOS.dll I receive a different error:

.load C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos clr

The call to LoadLibrary(C:\Windows\Microsoft.NET\Framework\v4.0.30319\sos clr) failed, Win32 error 0n126
    "The specified module could not be found."
Please check your debugger configuration and/or network access.

My setup is VM-to-VM over serial connection and both VMs are Windows Server 2008 R2 SP1. Debugging Tools For Windows (x64) is installed in both VMs.

NOTE: It appears installing x86 Debugging Tools on a x64 CPU as is suggested in this solution is not possible (nor necessary) in newer Windows OS's so please don't suggest it. The installer fails with an error.

Thanks in advance for your ideas.

2
what error message? i have seen plenty of x86 windbg installs on win7 64bitx29a
.load only takes the path to SOS, not clr at the end. If the x86 installer fails, please re-download. The x86 version and it is needed here, because you can't load a 32 bit DLL into a 64 bit process.Thomas Weller
My setup is VM-to-VM over serial connection. Why two VMs? Are you set up for kernel debugging?Marc Sherman
Note that the "specified module could not be found" is due to lack of escaping in the path, Doubling the backslashes gives the same "not a valid Win32 application" error as before.Deanna

2 Answers

18
votes

It is possible to install both x86 and x64 version of WinDbg on the same machine, and if you're debugging a 32 bit .NET app you should use the x86 version of WinDbg/SOS. The error message is telling you that you're trying to load the wrong version of SOS for the bitness of the application.

There's some additional guidance here.

11
votes

By default, the installer seems to put both 32-bit and 64-bit versions of WinDbg on the system without prompting - is it possible that you're running the wrong one?

Look in for an "x86" directory in the directory where WinDbg installed, and run the version of windbg.exe contained there.