0

I have a problem with debugging a ASP.NET Core project. It's about https://github.com/jasontaylordev/CleanArchitecture. You can start it with "dotnet run". I start it with "dotnet run waitfordebugger".

This is the snippet of the main method. The program sleeps for 20 seconds so that I can attach Visual studio to the process.

public async static Task Main(string[] args)
        {
            if (args[0] == "waitfordebugger")
            {
                Thread.Sleep(20000); // Wait 20 Seconds
            }
            int i = 0;
            i++;

I have set a breakpoint at "i++" in vs, started the application with "dotnet run waitfordebugger" and attached vs to the process. The problem is that the breakpoint is not hit. I get this warning:"The breakpoint will not currently be hit. No symbols have been loaded for this document.". Any ideas?

jps
  • 20,041
  • 15
  • 75
  • 79
ppp
  • 11
  • 4
  • Try adding `Debugger.Break()` instead of the Thread.Sleep. https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.debugger.break?view=net-5.0 – Carlos Magno Rosa Aug 06 '21 at 13:42
  • 1
    Does this answer your question? [How do I remedy "The breakpoint will not currently be hit. No symbols have been loaded for this document." warning?](https://stackoverflow.com/questions/2155930/how-do-i-remedy-the-breakpoint-will-not-currently-be-hit-no-symbols-have-been) – Sinatr Aug 06 '21 at 13:46
  • Seems like with .NET Core you would need to use Debugger.Launch() instead – Carlos Magno Rosa Aug 06 '21 at 13:54
  • Thanks! I have added Debugger.Launch() at the beginning of the Main method. Now the breakpoint works. – ppp Aug 06 '21 at 19:25

0 Answers0