Don't forget about pdb files when you can't debug on a remote machine

June 29, 2023

The problem

OK so you need to debug remotely again. You have the same os or at least the closest you can get, same .NET version, same tools installed but somehow there is some small difference somewhere and when you attach to remote machine VS will tell you you either can’t debug since it can’t load symbols or you see that although the code on your machine is the same as on the machine you remote debugger(ed) to (like you are on the same commit id) still the lines you see in your .cs files don’t match with lines the debugger is trying to show you like you step through comments…

What didn’t worked

I made a zip of folder of my web app with bin folder generated by msbuild on the server machine, I copied it over to my machine, attached to the server and… I got the same result I had with my code before.

The solution

If you can get your hands on the generated .pdb file you might be lucky since VS will let you try to load the generated pdb file and this is what saved me once again. VS will let you also use network share to load the pdb files so you might share bin folder to use the latest .pdb file there is on the machine if you recompile often. The question why generated .pdb differs with same .NET target version and with same sources stays one of several mysteries of the universe.

Where to tell VS to load pdb file

"browse and find pdb file"

Hope this helps.

Profile picture

Written by Dušan Roštár - the "mr edge case" guy
my twitter : rostacik, my linkedin : rostar, drop me an email : here