How do I debug a published XBAP file in VS2010? - c#

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.

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!

The Breakpoint will not currently be hit. No symbols where loaded for this document

Windows 8, VS2013 IIS8,5
I'm trying to connect to a local WEB API by connecting to processes w3pv.exe (Managed (v4.0.30319), 19). The website front end and back end is both running fine on my local IIS. Right after publishing my x86 web API to the local IIS i try to connect to the process, where the break point states "The Breakpoints will not currently be hit. No symbols where loaded for this document". My colleague' can without any problems debug from his local computer.
So far I have.
Reinstalled VS2013.
Checked All Debug Properties
-Project -> build: Define DEBUG constant check / Define TRACE constant check.
Generate serialization assembly = Auto. Advanced build settings -> Debug info = full
Enable Just My Code: Check, Use Managed Compatibility Mode: Check
Enable Edit and Continue : Check
Made sure all Debug mode is set and all project Configured to Active solution platform x86, marked Debug and Build.
Deleted all bin and obj folders, as well as pdb folder in C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files
Reset IIS.
Set Select Code Type to Automatically determine the type of code to debug
Checked in IIS that .Net compilation -> Debug and Enable Prefetch is set to true.
And I still get the same error message. Anyone found anything in addition to this?
I have encountered similar problems many times while training new employees in our very complicated devenv, so here is our internal step by step instruction:
Don't panic
Make sure you attached the debugger to the correct process - you debug the plugin by launching VMS which is external app that has separate config file where the plugin path is stored, so when you change just your configuration Debug/Release it doesn't work.
Make sure you have symbols generated for the assembly Project properties->Build->Advanced->Output section
Make sure the build path hasn't changed. You may have accidentally changed the path and you may only think that the assembly you are trying to debug is the correct one.
Investigating the information you provided this is only help I can think of. My guess is the files you publish are not the files you're debugging locally.
RESOLVED (embarrassed)
A few day's ago, I downloaded the front-end code for the website from the VPN (GIT). I forgot to update the code-behind reference in the App.js file in the front end root. This, of course, referred to the API on the cloud, and not my local API.
This took me way to long to find out. But, at the same time, it's not a solution I've seen so far on the web.
Thanks for all your help.

Cannot find debugging information when debugging c++ dll

there:
The Application is build from C#, and the Dll is built from C++, and they are in different solution. When I Launch the Dll's debugger, there is always a message box pop up, which says "Debugging information for 'App.exe' cannot be found or does not match.Skipped loading symbols for NGen binary."
Thanks.
p.s. I've try putting the App.pdb in several location, but still don't work.
As commented by ortang, you need to activate the debug info when building your project.
See "/DEBUG (Generate Debug Info) (Visual Studio 2013)":
The /DEBUG option creates debugging information for the .exe file or DLL.
The linker puts the debugging information into a program database (PDB). It updates the PDB during subsequent builds of the program.
It is not possible to create an .exe or .dll that contains debug information.
Debug information is always placed in a .pdb file.
To set this linker option in the Visual Studio development environment
Open the project's Property Pages dialog box. For details, see Setting Visual C++ Project Properties.
Click the Linker folder.
Click the Debugging property page.
Modify the Generate Debug Info property.

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.

Remote Debugging is not breaking on errors

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.

Categories

Resources