2

everyone! I try to debug my Blazor WASM project, but no matter which way I try debugging doesn't start. It doesn't work with VS Code, with Visual Studio 2019, with VS 2022. If I press Shift+Alt+D and then take browser launch parameters for debugging it seems to find source files, but freezes the working area and writes "Tab is inactive", so I can't pull any code from the sources. Like that:

https://www.screencast.com/t/3M8i3YckY

Both Visual Studios and VS Code wrote "Unbound breakpoint" or "No symbols have been loaded" depending on God knows what - at first. It would sometimes let me debug then, but the next debug launch didn't work out on the same browser. When I tried another, it worked, but just one extra time. When I ran out of browsers, I didn't know how to return to the state, when debugging was possible.

Now they (VSes and Code) just hang for a while after having opened the browser, and eventually shoot "could not connect to debug target. Promise was cancelled. Could not connect to localhost:????".

When I try to debug sample Blazor WASM project, it works well as expected.

Here is the launchSettings.json.

{
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:46330",
      "sslPort": 44369
    }
  },
  "profiles": {
    "IIS Express": {
      "commandName": "IISExpress",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
    },
    "Web.Client": {
      "commandName": "Project",
      "launchBrowser": true,
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "Development"
      },
      "dotnetRunMessages": "true",
      "applicationUrl": "https://localhost:5003;http://localhost:5002",
      "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}"
    },
    "Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}",
      "publishAllPorts": true,
      "useSSL": true
    }
  }
}

Here is the .csproj:

<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

  <PropertyGroup>
    <TargetFramework>net5.0</TargetFramework>
    <ServiceWorkerAssetsManifest>service-worker-assets.js</ServiceWorkerAssetsManifest>
    <UserSecretsId>1c3cafab-2f7d-4a06-b84c-46691a8e5dcf</UserSecretsId>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
  </PropertyGroup>

  <ItemGroup>
    <Content Remove="compilerconfig.json" />
    <Content Remove="wwwroot\css\MDB\css\NavMenu.css" />
    <Content Remove="wwwroot\css\NavMenu.css" />
    <Content Remove="wwwroot\css\standard-items\standard-items.css" />
    <Content Remove="wwwroot\css\standard-items\standard-items.scss" />
  </ItemGroup>

  <ItemGroup>
    <None Remove=".dockerignore" />
    <None Remove="Dockerfile" />
    <None Remove="Dockerfile.original" />
  </ItemGroup>

  <ItemGroup>
    <_ContentIncludedByDefault Remove="wwwroot\css\app.min.css" />
    <_ContentIncludedByDefault Remove="wwwroot\css\standard-items\standard-items.min.css" />
  </ItemGroup>

  <ItemGroup>
    <Protobuf Include="..\Web.Common\Services.proto" GrpcServices="Client" Link="..\Protos\Services.proto" />
  </ItemGroup>
  
  <ItemGroup>
    <PackageReference Include="Grpc.Net.Client" Version="2.38.0" />
    <PackageReference Include="Grpc.Net.Client.Web" Version="2.38.0" />
    
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="5.0.7" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="5.0.7" PrivateAssets="all" />
    <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="5.0.7" />

    <PackageReference Include="Grpc" Version="2.38.1" />
    <PackageReference Include="Grpc.Tools" Version="2.38.1" PrivateAssets="all" />
    <PackageReference Include="Google.Protobuf" Version="3.17.3" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.11.1" />

    <PackageReference Include="MudBlazor" Version="5.1.0" />

    <PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
  </ItemGroup>

  <ItemGroup>
    <ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
  </ItemGroup>

  <ItemGroup>
    <None Include="compilerconfig.json" />
    <None Include="wwwroot\css\MDB\scss\NavMenu.scss" />
    <None Include="wwwroot\css\NavMenu.css" />
    <None Include="wwwroot\css\standard-items\standard-items.css">
      <DesignTime>True</DesignTime>
      <AutoGen>True</AutoGen>
      <DependentUpon>standard-items.scss</DependentUpon>
    </None>
    <None Include="wwwroot\css\standard-items\standard-items.scss">
      <Generator>SassTranspiler</Generator>
      <LastGenOutput>standard-items.css</LastGenOutput>
    </None>
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Web.Common\Communication.csproj" />
  </ItemGroup>

  <ItemGroup>
    <Folder Include="wwwroot\css\standard-items\Inputs\" />
    <Folder Include="wwwroot\css\standard-items\Cards\" />
  </ItemGroup>

  <ItemGroup>
    <None Remove="..\.dockerignore" />
  </ItemGroup>

</Project>

Please help, because I badly languish without client debugging.

UPDATE: I managed to get rid of the "Tab is inactive" message, but the breakpoints don't get hit.

destallon
  • 21
  • 3
  • I had a similar problem. I found a workaround, see [my answer here](https://stackoverflow.com/a/72037574) for working config. – lonix Apr 28 '22 at 03:21

2 Answers2

0

This workaround worked for me (on Visual Studio 2019.11.4, using Chrome version 94.0...): I cleaned the solution and rebooted my PC.

philu
  • 795
  • 1
  • 8
  • 17
0

I'm currently still utterly confused about this, but if I move the window from my secondary monitor to my primary then the debugging works. Sometimes.

And it didn't like Edge (the chromium version) for Ctrl + Shift + D debugging, and I had to use Chrome.

Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689