runtime: [.NET 6] Blazor cannot find member named xxx while debugging

Describe the bug

Hi. I tried to upgrade my project to .net 6 rc and met problem when debugging my app.

If I set breakpoint inside my method (event method for dropdown element), Blazor throws exceptions and never step to this breakpoint again until reload project.

Blazor send this: fail: Microsoft.WebAssembly.Diagnostics.DevToolsProxy[0] sending error response for id: msg-52D572BE3642D3EDFFB06D7556619E0D:::1028 -> [Result: IsOk: False, IsErr: True, Value: , Error: { "result": { "type": "object", "subtype": "error", "description": "Cannot find member named 'GetTranslationsFromServer'.", "className": "ReferenceError" } } ] fail: Microsoft.WebAssembly.Diagnostics.DevToolsProxy[0] sending error response for id: msg-52D572BE3642D3EDFFB06D7556619E0D:::1031 -> [Result: IsOk: False, IsErr: True, Value: , Error: { "result": { "type": "object", "subtype": "error", "description": "Cannot find member named 'Enum'.", "className": "ReferenceError" } } ] fail: Microsoft.WebAssembly.Diagnostics.DevToolsProxy[0] sending error response for id: msg-52D572BE3642D3EDFFB06D7556619E0D:::1040 -> [Result: IsOk: False, IsErr: True, Value: , Error: { "result": { "type": "object", "subtype": "error", "description": "Cannot find member named 'Enum'.", "className": "ReferenceError" } } ]

My method just do this:

var language = LanguageHelper.GetSupportedCultureByLanguage(
                (SupportedLanguages)Enum.Parse(typeof(SupportedLanguages), selectedLanguage));
public string GetSupportedCultureByLanguage(SupportedLanguages language)
        {
            return language switch
            {
                SupportedLanguages.English => "en-GB",
                SupportedLanguages.Polish => "pl-PL",
                SupportedLanguages.Russian => "ru-RU",
                _ => "pl-PL",
            };
        }

To Reproduce

Create any test enum, for example:

public enum TestEnum
    {
        Test,
        Test2
    }

after that try to debug this line of code Enum.Parse(typeof(TestEnum), "Test");

For new project, I see exception but debugger continues to work. For my own project, as I said, debugger never hit breakpoint again

Browser console is always empty

Further technical details

  • NET 6.0.100-rc.2.21505.57
  • Visual Studio 2022 Community RC2

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (14 by maintainers)

Most upvoted comments

Because VS tries to evaluate automatically some expressions, I don’t know exactly how they decide what they are trying to evaluate, but it makes sense to fail, once we don’t have any variable or property named ‘Enum’ in this method.

I’ll probably remove these messages, but they are not affecting the debugging experience.

Oh, probably that is why it’s not working the debugging anymore. I have already fixed it. I will let you know when this is in a version that you can use. It’s not in a public version yet.