Blazor client-side debugging

后端 未结 6 1286
别那么骄傲
别那么骄傲 2021-01-01 11:47

I noticed that all of my C# breakpoints do not get hit as debugging seems like its disabled for client-side Blazor apps.

Is there a way to attach the debugger or ena

6条回答
  •  一整个雨季
    2021-01-01 12:22

    This is a known issue in Blazor projects at this time. The debugger launches slower/quicker than the project assembly and doesn't have time to "see" the assembly. Here is my fix until they solve this. I add a delay in Program.cs so that when the project launches in debug mode, it gives the debugger time to attach properly. I used 5000 ms but you may have to increase this value if your machine is slower than mine.

    public class Program
    {
        private static async Task DebugDelayAsync()
        {
    #if DEBUG
            await Task.Delay(5000);
    #endif
        }
    
        public static async Task Main(string[] args)
        {
            await DebugDelayAsync();
    
            (...)
        }
    }
    

提交回复
热议问题