问题
The way we are used to debug a running "IISExpress" process in .Net Framework is by attaching a process by the name "iisexpress.exe" in Visual Studio. But attaching the iisexpress process is not working in .Net core. It shows the message - "The breakpoint will not currently be hit. No symbols have been loaded for this document."
回答1:
To debug a running iisexpress instance in .Net core, you will have to attach "dotnet.exe" process in Visual Studio.
回答2:
In my case, using Asp.Net Core 2.2 with InProcess
Hosting Model, the accepted answer doesn't work. But, I should choose from the menu Debug
> Attach to process
, then select the "Show processes from all users" checkbox (below the list of process) and select "iisexpress.exe". It works properly and hit the break points.
回答3:
In Visual Studio 2019 using "dotnet watch run" I could no longer attach to the "dotnet.exe" process, I would get the Symbols could not be loaded error, took me a while to figure out but instead I attached to [project name].exe which is in the list of running processes and I could successfully attach the debugger to a process with symbols loaded and debug.
回答4:
Visual studio does not loads all dlls (don't know why). Try this:
1) First attach with w3wp.exe (for InProcess Hosting) or dotnet.exe (for OutOfProcess Hosting)
2) Load Symbols manually:
Go to Debug > Windows > Modules (or try shortcut Ctrl + Alt + U)
Search and select dll (and dependent dll's) which you want to debug and right click > Load Symbols.
来源:https://stackoverflow.com/questions/49297775/asp-net-core-debug-attach-to-process-is-not-working