C# Remote Debugger - Cannot find or open the PDB file - c#

I'm trying to remote debug my application (C# windows application) according to Remote Debugging, I installed the Remote Tools on my remote machine, say it's RA, and I added permission for the machine I want to debug the application, say it's B.
I open VS in B, Click Debug->Attach to Process..., choose 'Remote =(no authenticated) in Transport, then click the Find button and I can find the machine RA. When I selected this machine and choose the application I'm going to debug, but when I attach it, there's a lot log messages showing that Cannot find or open the PDB file.
Since we need the pdb files to debug on our local machine, then how remote debugging find the pdb files? Or I didn't have it configured correctly on RA?

Confirm yourself that you can access the pdb files, located on RA, from B. First step is to make a network share of the directory where the pdb's are located on RA. Second step is to open a windows explorer on B and navigate to that specific network share. For example: \\RA-MACHINE\PDB-DIR. Log in with the correct credentials (RA-DOMAIN\RA-USER, RA-PWD) and tell it to remember your credentials for subsequent logins. The pdb-files should show up in the windows explorer. Configure where the debugger looks for symbol files, as described [here] and remote debugging should work.

According to https://msdn.microsoft.com/library/x54fht41(v=vs.100).aspx
By default, the debugger loads symbol files from the location where
your EXE is located. To use symbols from another directory or a symbol
server, you must specify the locations to Visual Studio.

If you use Azure pipelines with VS 2022 and your .pdb file is present in your web app, you have to publish manually in VS with a profile and then attach the debugger. I tried to get my pipeline to update the .pdb file but was unsuccessful. I never had this issue with VS 2019.

Related

Why is my C# web project looking for a local file once it is uploaded to remote server (with code behind)? [duplicate]

I am using C#.net for application development.
To log and debug exceptions, I use the stacktrace.
I executed my application on another machine, but when errors occur it refers to the path of my development machine.
Ex: D:\Projects\xyz.CS line no :12 _Error_message_here.
Why does it trace to the path on my development machine path even though I am running the application on another machine?
The original compiled path is stored in the debug information within the PDB files.
Because it's telling you where to find the problem in your source code. So when you see this, you can go to your machine and open the file reported (e.g. "D:\Projects\xyz.cs"), go to the reported line (e.g. 12) and fix the problem.
Explanation
When you do a Debug build, it includes source information in the compiled files to enable debugging, e.g. pause, step over, etc.
Solution
If you don't want the source information to be included perform a Release build and deploy that to the other machine.

Symbols not loading from Symbol Server

I have followed the directions and I created and loaded my symbols into my local Symbol Server path. I added the path C:\SymbolServer to the .pdb locations in VS.
I also disabled Just My Code and Enabled Source Server Support. However, everytime I debug my program and look at the modules window it says it loads from the default path where the project is located.(C:\Users\mcgeedm\documents..) and I want it to load from C:\SymbolServer. I am using VS 2012.
That behavior you are trying to get seems odd.
When you run an application from Visual Studio it automatically resolves the assembly and it's PDB files from the application directory. If it can't find it, it will try to load it from another location, which includes the symbol directory. That's just the way it works and should work in my opinion.

Open Minidump : No native symbols in symbol file

In a C# project, I create minidump at UnhandledException.
In my Dev machine, project source and bin are under path K:\projects\*MYPROJECT*, if I manage to let it crash in my Dev machine, everything work perfectly, I can open the minidump file and correctly see source code, callstack, threads etc.
End-user program path will obviously be different; as an example, in our Test machine project is installed under C:\*MYPROJECT*. It's deployed with pdb symbol files. Anyway, when I try to open the minidump, generated on that machine, on my Dev computer (where I have the source files), Visual Studio try to find the executable and pdb file under "Test Path" (C:\*MYPROJECT*) without of course find it.
I tried setting Symbol path to include K:\projects*MYPROJECT* without any result, so I recreated the same Test directory structure, creating C:\*MYPROJECT* and copying .exe and .pdb files under that directory. Now, Visual Studio is be able to find them, but it's saying "No native symbols in symbol file", and it doesn't let me see any source code.
How can I accomplish to load the correct Symbols?
To change the directory, Microsoft describes to open the immediate window and type .exepath [path] to change it.
You can also use .srcpath [path] and .sympath [path].
Finally came across a solution.
After weeks trying to figure out what I were missing, I've found that on my development machine I have a different Framework version (in details, I have v4.0.30319.18444 vs v4.0.30319.17929 on test machine). I still don't understand why I shouldn't be able to debug my application without having the exact Framework version, but the solution was to copy mscordacwks.dll and mscordbi.dll (both of them found in C:\Windows\Microsoft.NET\Framework) from the Test machine to the folder where the minidump is.
Reference:
Managed Minidump Debugging in SP1

Using Visual Studio 2010 to remote debug a C# .dll -- getting .PDB file does not match - any yet it is absolutely the from the build

Using Visual Studio 2010 to remote debug a C# .dll -- getting .PDB file does not match - any yet it is absolutely the from the build...............
New info: [[ This problem is not resolved. I have three computers: a)XP sp3, b)XP sp3 and c)Vista sp1, I can build the simplest of test programs on a) and c), and using the module window -- select my test5.exe and load the .pdb that was created when it was created - same date same time same folder... and yet Visual Studio says "a matching symbol file was not found in this folder" -- all efforts to load the correct .pdb fail with not matching complaint.... be it: a) remote to b) or c) -or- c) remote to a) or b) --- HELP! ]]
I have set the location of the .PDB implicitly and explicitly - does not matter....
I have set the symbol settings to be unchecking that source files must match exactly....
I am seeing no Errs....
Just:
C:\POSWIN\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
C:\Projects\SP\DBS.KGW.tst7STUB\DBS.KGW.tst7\obj\Debug\DBS.KGW.tst7.pdb: PDB does not match image.
C:\Projects\SP\DBS.KGW.tst7STUB\DBS.KGW.tst7\bin\Debug\symbols\DLL\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
C:\Projects\SP\DBS.KGW.tst7STUB\DBS.KGW.tst7\bin\Debug\DLL\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
C:\Projects\SP\DBS.KGW.tst7STUB\DBS.KGW.tst7\bin\Debug\DBS.KGW.tst7.pdb: PDB does not match image.
C:\Projects\SP\DBS.KGW.tst7STUB\DBS.KGW.tst7\bin\Debug\MicrosoftPublicSymbols\symbols\DLL\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
C:\Projects\SP\DBS.KGW.tst7STUB\DBS.KGW.tst7\bin\Debug\MicrosoftPublicSymbols\DLL\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
C:\Projects\SP\DBS.KGW.tst7STUB\DBS.KGW.tst7\bin\Debug\MicrosoftPublicSymbols\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
C:\WINDOWS\symbols\DLL\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
C:\WINDOWS\DLL\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
C:\WINDOWS\DBS.KGW.tst7.pdb: Cannot find or open the PDB file.
A couple of suggestions:
In visual studio, while you are attached to the process, open the modules debug window, Ctrl+D, M (or Debug -> Windows -> Modules from the menu) and find the dll that's causing issues. Right click it and select Load Symbols From and then Symbol Path locate the correct pdb file and see if it loads.
If you're app is asp.net, then you could try clearing the temp folder as it sometimes causes problems similar to yours. That folder should be located somewhere like this:
bootdrive:\%windir%\Microsoft.NET\Framework\v2.0.5 0727\Temporary ASP.NET
Depending on your .net version.
The solution is that for remote debug connections there are two ways to connect, authorized and unauthorized... For firewall issues, I defaulted to unauthorized. For VS 2010 C# solutions the complaint is merely the .PDB does not match. Having exhausted all options I could think of I went and reproduced my simple test solution in C++, the interface is different and better and there is a warning as you set this up that you will not get symbols unless you are on an authorized connection!!! -- Once I overcome the firewall issue -- and see my symbols via an authorized connection to the remote PC that is being debugged, I will post that confirmation...... btw, often it is warned that when you sign-on via an authorized connection the user ID and password for both the host and debugged computer must be the same, furthermore the user on the debugged computer must have "logon as service" right added to its user.....
I have got same problem and solution was so easy...
In my case, I have two VS solutions, first is main app with .exe and second .dll plugin project. When I tried to debug a dll project, I get a pdb not matching error (in module window). The reason was that pdb was actually not matching at all because:
When I was testing first solution, I copy .dll file from second solution to debug folder with .exe file.
Then when I tried to debug second (.dll) solution, it was using .exe file from first solution AND ALSO THE .dll file in that directory, but that .dll was outdated and didnt match with new pdb file. So copying a new .dll file from second project to .exe directory resolved my problem.

Remote-Debugging in Running Web Application

We are trying to add a new page to a running web application. such that a new dll and aspx file are being added. I've setup break points in the code file and Built the application transfering the dll to the remote machine bin file and the aspx page to a folder within the web application. Note this folder is not in the same folder hierarchy as it built in. I'm not sure if thats the problem. Basically we are appending new functionality to a web application.
I've completed the following
I've copied the correct Remote Debug Monitor to the server and have it running.
I'm able to attach to the process which in this case is w3wp.exe (I've Identified that it is the correct process for my application.
I deployed the *.dll to the the bin folder with the *.pdb file along with it.
I've deployed the *.aspx file to the location we want.
With the file open in visual studio with breakpoints setup, we attach to the process and debug. I get 'No symbols loaded' and the breakpoint go empty.
I'm missing something it seems. I've searched the net but have only found complete publish\ deployment scenario.
Any thoughts
Tools -> Options -> Symbols -> Add the path to your deployed web application dlls and pdbs.
You might also need to uncheck "Enable Just My Code" under general debugging.
Here's a more detailed answer that got it working for me in the past: Remote Debugging is not breaking on errors

Categories