Remote Debugging is not breaking on errors - c#

I am fairly new to remote debugging in Visual Studio, and by new I mean I have never done it before. Here are the steps I have taken to try to remotely debug an application on one of the servers in our network:
open a website in VS2008 "\\server\website"
Start the msvsmon service on "server" with "no authentication" and "allow any user to debug"
From VS2008, Attach to the w3wp process on "server" using remote transport
debugging starts and everything seems ok, but when i go to the page with the error, it doesn't break and let me debug. Am I missing something?

You need to ensure you have the PDB files loaded correctly.
Visual Studio is going to look in that remote location for the PDB files (which contain the debugger information) and if it doesn't find them it doesn't have the necessary debug symbols to break on.
To add a pathname to the symbol file (.pdb or .dbg) locations list
On the Tools menu, choose Options.
In the Options dialog box, click the Debugging node to open it.
Under Debugging, select the Symbols category.
On the Symbols page, there is a box that says Symbol file (.pdb) locations. Above the box are four icons. Click the folder icon and editable text appears in the Symbol file (.pdb) locations box.
Edit the text to add a new path. Statement completion helps you get the format right.
Make sure Search the above locations only when symbols are loaded manually is not selected, unless you want to load symbols manually when you debug.
If you are using symbols on a remote symbol server, you can improve performance by specifying a local directory that symbols can be copied to. To do this, use the Cache symbols from symbol server to this directory box. Note that if you are debugging a program on a remote computer the cache directory refers to a directory on the remote computer.
Click OK.
http://msdn.microsoft.com/en-us/library/x54fht41.aspx

Here's a checklist.

Related

Visual studio modules window shows .aspx files instead of DLL name

I am working on an ASP.NET project and getting the dreaded The breakpoint will not currently be hit. No code has been loaded for this code location.
I am running in debug configuration, and other projects in the same solution can be debugged properly.
I'm using Visual Studio 2017 Community edition, in the modules window I see an empty list, I have to right click and select Show Modules for all Processes to get anything to appear, and when it appears it does not show the name of the .dll, it shows the name of the .aspx page that the launched browser is currently sitting on, which will update as I navigate around the site.
From all the answers I have found online, it should be showing the name of my project's .dll file, such as MyProject.dll, then you can manually load the symbols from there by looking in the bin directory for MyProject.pdb (which does exist), but I am seeing the page name, Register.aspx, which of course will not work if I try to load the symbols for MyProject.pdb.
Or maybe I'm totally off-base here, I'm happy to provide any info that might help!

Slow symbol loading in an ASP.NET Project in VS2012

I'm having an issue with loading symbols on my ASP.NET MVC project. The first time I load visual studio and debug my project, symbols are loaded in roughly 2 seconds. I then end the debug session, make a code modification, and debug again, and the symbol load time is about a minute. Based on the research I have done, here are some applicable settings on my machine/VS:
In Options/Debugging/Symbols/Symbol file locations, "Microsoft Symbol Servers" is unchecked, and there are no additional locations.
Options/Debugging/Symbols/Cache symbols in this directory is "G:\Symbol Cache". I did click "Load all symbols" and I have inspected that directory and I see lots of symbols.
Just my code is enabled.
The _NT_SYMBOL_PATH and _NT_ALT_SYMBOL_PATH environment variables are not defined on my machine.
Options/Debugging/Symbols/Automatically load symbols for is set to "Only specified modules", with no modules specified.
I have tried both debug and release builds, with identical results. Ctrl + F5 loads the site almost immediately.
I too had this problem, the cause was that I had accidently enabled the "Microsoft Symbol Server"
You can disable it by going to Tools > Options > Debugging > Symbols and uncheck the "Microsoft Symbol Server"
Now it loads just as fast as it used to.
I too had this problem and noticed that it was mostly related to 3rd-party assemblies acquired via NuGet. In these cases, Visual Studio was trying to load PDBs from paths that apparently existed on the original author's machine (i.e. D:\OriginalAuthor\MyVisualStudioProjects\AwesomeNuGetPackage) but on my machine the same path referred to an optical drive. I then discovered via Command Prompt that if you tried to change directory to an optical drive that didn't have a disc in the tray, it took a very long time (~30 seconds) to fail. With this in mind, my solution was to simply place a DVD in the tray. At that point Visual Studio was able to very quickly determine that the path didn't exist, skip loading the PDB, and go straight into debug.
So, if Visual Studio is taking a long time to load symbols, watch the Output window for the paths it's trying to access and verify that you can quickly access (or quickly fail to access) those paths yourself via Command Prompt.
This brings up an interesting question about security/privacy--apparently Visual Studio is storing the absolute path of the original PBD within the assembly. I suppose this isn't a super critical issue, but from a privacy perspective I don't really want my absolute filesystem paths being exposed to the public without my knowledge.
Just try this Debug -> Delete All Breakpoints.
Its works on me.
I had 2 .dll's giving me grief that I didn't need to debug that started taking minutes to load. The afore mentioned solutions didn't help. So I went to Options -> Debugging -> Symbols and under the radio button for "All modules, unless excluded" click on "Specify excluded modules" link. Then type the .dll's that are causing issues.

How do I load debugging symbols for a DLL in Visual C# Express 2010?

I'm writing an app in Visual C# 2010 Express. I want to step-into some code in a DLL to debug it. The DLL and its whole source tree are on my same PC. How do I load the symbols for it?
Googling for an answer says to use Debug > Windows > Modules when in run or debug mode. But I don't see any option for Modules there and http://msdn.microsoft.com/en-us/library/4c8f14c9%28v=vs.100%29.aspx suggests that Express doesn't get a Modules Window. So how should I load the symbols so I can step into my DLL?
Thanks in advance.
I found a workaround, that worked in this case, i.e. where the DLL build project was on my PC . . .
Open the window for Tools > Options
Check the checkbox in the lower left corner labeled "Show all
Settings"
From the tree view expand Debugging > Symbols window
There's a multiline text box with a label "Symbol file (.pdb)
locations:"
To the right of that label a row of icons
Click the icon that looks like a new folder icon; this will produce
an empty edit line with a checkbox
Type in the complete path of the folder where the .PDB file is to be
found Check the checkbox and exit options.
With this I was able to step through the code in the DLL and see variables.
Debug -> Attach To Process and find the process that has loaded your .dll

Exception shows developer's path instead of servers

When an exception occurs with any ASP.NET project (possibly any .net app) the stack trace will show the path on the developer's machine, even when in production.
How to change it?
What's going on under the hood?
This information is stored inside the .PDB files that were generated during the compilation of the source code. They contain the debugging information. But normally people don't compile applications on their machines before shipping them into production. They use continuous integration and build servers that are dedicated for this purpose.
Now if you want to turn off debugging details you could configure the level of verbosity and debug info in the properties of your project.
In order to remove it, go to Properties -> Package/Publish Web:
Make sure to click or check the "Exclude generated debug symbols".
This will Publish your site without PDB files attached on the Bin folder. Make sure you are on Release mode before publishing your site for Live environment. One of the main difference of publishing your site without PDB files is that you cannot see the line number on the StackTrace when an error happens on your site.

How do I debug a published XBAP file in VS2010?

I need to debug a full-trust application either by specifying a URL or, ideally, from within the web app I am intending to deploy it to. I've tried the following:
Running "PresentationHost.exe -embedding" from the command-line, attaching through Visual Studio. The IDE shows that my breakpoints are valid until I actually attempt to load the .xbap file, at which point it shows that there are no symbols loaded. None of my breakpoints are hit. I've tried "mage -cc" before doing this per several recommendations elsewhere.
Hard-coded URL in the project's Debug panel then F5. Alternatively, "PresentationHost.exe -embedding -debug" and attach to process then load the .xbap in IE. Both result in the following error when the page appears:
System.ArgumentException: URI formats are not supported.
at System.IO.Path.NormalizePath(...)
at System.IO.FileStream.Init(...)
at System.IO.FileStream..ctor(...)
at System.Windows.Interop.ApplicationLauncherXappDebug.GetIdFromManifest(...)
at System.Windows.Interop.ApplicationLauncherXappDebug.GetApplicationIdentity()
at System.Windows.Interop.ApplicationLauncherXappDebug.Initialize()
at System.Windows.Interop.DocObjHost.MS.Internal.AppModel.IBrowserHostServices.Run(...)
Found it. The "PresentationHost.exe -embedding" will work, provided that you select the .pdb file to be published, which it is not by default. This follows from what I saw before, where the debugger appeared to have symbols then not, once the app actually loaded. To clarify:
Go into the Publish tab on the project properties
Click "Application Files..."
Check "Show all files"
Select the .pdb file for the executable to be included.
Republish
PresentationHost.exe -embedding
Attach to process or set the project to run this out of the debug tab
Launch the web page in a browser and navigate to the xbap file, breakpoints should be hit now.
If you have access to source code and you deploy on localhost you can simply add System.Diagnostics.Debugger.Launch(); in your code. This will allow You to attach with VS to any process your XBAP is using.

Categories

Resources