Repository navigation
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
When I try to debug my Blazor Wasm application (cs files), I got stucked with debugger. Debugger not hit and I got some wierd error on visual studio and in console. I didn't find any resolution during my research last 5 days.
I need help ASAP because we really cannot accept situations like this, We are big fan of Blazor and .NET stack but unfortunatelly if we do not solve this issue we cannot continue our projects in this technology, it is not acceptable to have issues like this.
It worked before but now there is no chance to make it work again. I didn't change anything in my code base but windows updates, visual studio update.
I did re-installed all SDK-s, re-installed visual studio, even check .NET core 8 preview, but without success.
It is important to mention that i'm using authentication, (OpenIdDict).
.NET 7, VS 17.6.2
Expected Behavior
Expecting to have working debbuger breakpoints inside razor.cs files.
Steps To Reproduce
Exceptions (if any)
[14:07:12] fail: DevToolsProxy[0]
failed: Microsoft.WebAssembly.Diagnostics.DebuggerAgentException: SendDebuggerAgentCommand failed for GetAssemblyByName: [Result: IsOk: False, IsErr: True, Value: , Error: {
"result": {
"type": "object",
"subtype": "error",
"className": "ReferenceError",
"description": "ReferenceError: getDotnetRuntime is not defined\n at <anonymous>:1:1",
"objectId": "8627393451561219652.5.9"
},
"exceptionDetails": {
"exceptionId": 9,
"text": "Uncaught",
"lineNumber": 0,
"columnNumber": 0,
"scriptId": "518",
"stackTrace": {
"callFrames": [
{
"functionName": "",
"scriptId": "518",
"url": "",
"lineNumber": 0,
"columnNumber": 0
}
]
},
"exception": {
"type": "object",
"subtype": "error",
"className": "ReferenceError",
"description": "ReferenceError: getDotnetRuntime is not defined\n at <anonymous>:1:1",
"objectId": "8627393451561219652.5.10"
}
}
} ]
at Microsoft.WebAssembly.Diagnostics.MonoSDBHelper.SendDebuggerAgentCommand[T](T command, MonoBinaryWriter arguments, CancellationToken token, Boolean throwOnError)
at Microsoft.WebAssembly.Diagnostics.MonoSDBHelper.GetAssemblyId(String asm_name, CancellationToken token)
at Microsoft.WebAssembly.Diagnostics.MonoProxy.SetMonoBreakpoint(SessionId sessionId, String reqId, SourceLocation location, String condition, CancellationToken token)
at Microsoft.WebAssembly.Diagnostics.MonoProxy.SetBreakpoint(SessionId sessionId, DebugStore store, BreakpointRequest req, Boolean sendResolvedEvent, Boolean fromEnC, CancellationToken token)
at Microsoft.WebAssembly.Diagnostics.MonoProxy.OnSourceFileAdded(SessionId sessionId, SourceFile source, ExecutionContext context, CancellationToken token)
at Microsoft.WebAssembly.Diagnostics.MonoProxy.LoadStore(SessionId sessionId, Boolean tryUseDebuggerProtocol, CancellationToken token)
at Microsoft.WebAssembly.Diagnostics.MonoProxy.LoadStore(SessionId sessionId, Boolean tryUseDebuggerProtocol, CancellationToken token)
.NET Version
7.0.302
Anything else?
Dotnet Info:
dotnet --info
.NET SDK:
Version: 7.0.302
Commit: 990cf98a27
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.302\
Host:
Version: 7.0.5
Architecture: x64
Commit: 8042d61b17
.NET SDKs installed:
5.0.402 [C:\Program Files\dotnet\sdk]
6.0.100 [C:\Program Files\dotnet\sdk]
6.0.401 [C:\Program Files\dotnet\sdk]
7.0.101 [C:\Program Files\dotnet\sdk]
7.0.203 [C:\Program Files\dotnet\sdk]
7.0.302 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.20 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.11 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Other architectures found:
arm64 [C:\Program Files\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation]
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]
Environment variables:
Not set
global.json file:
Not found
Project.cs
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.5" PrivateAssets="all" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="7.0.5" />
<PackageReference Include="Microsoft.AspNetCore.SignalR.Client" Version="7.0.5" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="7.0.5" />
<PackageReference Include="MudBlazor" Version="6.4.1" />
<PackageReference Include="FluentValidation" Version="11.5.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Common.Dtos\Common.Dtos.csproj" />
<ProjectReference Include="..\Common.Enums\Common.Enums.csproj" />
</ItemGroup>
<ItemGroup>
<ServiceWorker Include="wwwroot\service-worker.js" PublishedContent="wwwroot\service-worker.published.js" />
</ItemGroup>
<PropertyGroup>
<BlazorWebAssemblyLoadAllGlobalizationData>true</BlazorWebAssemblyLoadAllGlobalizationData>
</PropertyGroup>
</Project>
App.razor
<CascadingAuthenticationState>
<Router AppAssembly="@typeof(Program).Assembly">
<Found Context="routeData">
<AuthorizeRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)">
<NotAuthorized>
@if (!context.User.Identity.IsAuthenticated)
{
<RedirectToLogin />
}
else
{
<p>You are not authorized to access this resource.</p>
}
</NotAuthorized>
<Authorizing>
</Authorizing>
</AuthorizeRouteView>
</Found>
<NotFound>
<LayoutView Layout="@typeof(MainLayout)">
<p>Sorry, there's nothing at this address.</p>
</LayoutView>
</NotFound>
</Router>
</CascadingAuthenticationState>
Example of some page which requires Authenticated user
@page "/"
@attribute [Authorize(Roles = "TENANT")]
<h1>test</h1>
Index.html Scripts:
<script src="_framework/blazor.webassembly.js"></script>
<script src="_content/Microsoft.AspNetCore.Components.WebAssembly.Authentication/AuthenticationService.js"></script>
<script src="_content/MudBlazor/MudBlazor.min.js"></script>
Program.cs
using Cockpit.Blazor;
using Cockpit.Blazor.Auth;
using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.JSInterop;
using MudBlazor.Services;
using System.Globalization;
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");
builder.Services.AddLocalization();
CultureInfo cultureInfo;
var jsInterop = builder.Build().Services.GetRequiredService<IJSRuntime>();
var appLanguage = await jsInterop.InvokeAsync<string>("appCulture.get");
if (appLanguage != null)
{
cultureInfo = new CultureInfo(appLanguage);
}
else
{
cultureInfo = new CultureInfo("en-US");
await jsInterop.InvokeVoidAsync("appCulture.set", "en-US");
}
CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;
builder.Services.AddMudServices();
builder.Services.AddTransient<BlazorWasmAPIsAuthorizationMessageHandler>();
builder.Services.AddHttpClient("CommunityAPI", client => client.BaseAddress = new Uri("https://localhost:7121/")).AddHttpMessageHandler<BlazorWasmAPIsAuthorizationMessageHandler>();
builder.Services.AddHttpClient("MembershipAPI", client => client.BaseAddress = new Uri("https://localhost:7257/")).AddHttpMessageHandler<BlazorWasmAPIsAuthorizationMessageHandler>();
builder.Services.AddHttpClient("NotificationAPI", client => client.BaseAddress = new Uri("https://localhost:7099/")).AddHttpMessageHandler<BlazorWasmAPIsAuthorizationMessageHandler>();
builder.Services.AddHttpClient("OrderAPI", client => client.BaseAddress = new Uri("https://localhost:7056/")).AddHttpMessageHandler<BlazorWasmAPIsAuthorizationMessageHandler>();
builder.Services.AddHttpClient("TenantAPI", client => client.BaseAddress = new Uri("https://localhost:7221/")).AddHttpMessageHandler<BlazorWasmAPIsAuthorizationMessageHandler>();
builder.Services.AddOidcAuthentication(options =>
{
options.ProviderOptions.ClientId = "cockpit-client";
options.ProviderOptions.Authority = "https://localhost:7060";
options.ProviderOptions.ResponseType = "code";
options.ProviderOptions.RedirectUri = "https://localhost:7236/authentication/login-callback";
options.ProviderOptions.PostLogoutRedirectUri = "https://localhost:7236/authentication/logout-callback";
options.ProviderOptions.ResponseMode = "query";
options.AuthenticationPaths.RemoteRegisterPath = "https://localhost:7060/Identity/Account/Register";
options.ProviderOptions.DefaultScopes.Add("openid");
options.ProviderOptions.DefaultScopes.Add("roles");
options.ProviderOptions.DefaultScopes.Add("email");
options.ProviderOptions.DefaultScopes.Add("profile");
options.ProviderOptions.DefaultScopes.Add("apis");
options.UserOptions.RoleClaim = "role";
});
await builder.Build().RunAsync();
BlazorWasmAPIsAuthorizationMessageHandler.cs
public class BlazorWasmAPIsAuthorizationMessageHandler : AuthorizationMessageHandler
{
public BlazorWasmAPIsAuthorizationMessageHandler(IAccessTokenProvider provider,
NavigationManager navigationManager)
: base(provider, navigationManager)
{
ConfigureHandler(
authorizedUrls: new[] { "https://localhost:7121", "https://localhost:7257", "https://localhost:7099", "https://localhost:7056", "https://localhost:7221" },
scopes: new[] { "email", "profile", "roles", "openid", "apis" });
}
}

Activity
[-]Blazor Wasm debugger not working anymore[/-][+][wasm][7.0] Blazor Wasm debugger not working anymore[/+]DinoHad commentedon Jun 14, 2023
Same issue with .NET (v7.0.304) and 7.0.7 packages.
Is there and advice or bypass to make debugger working again, our projects are totally blocked.
thank you guys.
DinoHad commentedon Jun 14, 2023
When I open page which should hit debugger (method: OnInitializedAsync):
DinoHad commentedon Jun 14, 2023
ilonatommy commentedon Jun 14, 2023
Thank you for the report, @DinoHad. I was trying to reproduce but with no effect so far. Generally this kind of error (
getDotnetRuntime is not defined) should be displayed when the debugger action is triggered on non-wasm page. Let me ask you some questions.Did you try debugging in Browser (ctrl+alt+D on the browser's window) or only in Visual Studio? Does it finish with the same error for both?
Does it happen only on your big project? What about a simple template project? Does it happen every time you trigger debugging action (hit breakpoint/step in etc) or only in specific situations?
Does it mean that if you remove the authentication from the project, the behavior changes?
DinoHad commentedon Jun 14, 2023
Hi @ilonatommy , thank you for your respond!
After we didn't success to debug via Visual studio, we tried to debugging in Browser but without success (we got some popup error 'websocket disconnected' sth like that.
We have 5 projects in Blazor Wasm in different solutions and all of them are blocked now and they have same structure and architecture and all of them struggling with debugging. All Blazor Wasm projects rely on same Authentication structure with OpenIdDict because our projects are based on logged in user data and each operation on application required logged in user and information from that user.
What we figured out is that
AuthorizeRouteViewis some kind of blocker, for example when we use App.razor from blank new project which doesn't haveAuthorizeRouteViewand only haveRouteViewdebugger works, but it is useless for us because of need for data from logged in user.So, removing authentication helps to debugger to work again, yes. Actually as I mentioned above.
Yes, it is same on other team members
ilonatommy commentedon Jun 16, 2023
I kind of reproduced on 7.0.5 when the app has another, authorization problem but am still looking for ways how to fail debugging a correctly set up application. In the meantime, please make sure your authorization setup is correct.
Repro steps:
dotnet new blazorwasm --auth Individualor using the tutorial.Do not set up the db - authorization will fail for sure.
Result: "Frame not in module" in VS, as on the screenshot.
Will keep you posted on the progress.
DinoHad commentedon Jun 18, 2023
it seems comment of EricCornelson on this issue: #86754 (comment) resolved this one also, debugger/break points is now hitted, but there is still error persistent in console while App is running in Debug mode and debugger hit break point.
error:
thaystg commentedon Jun 20, 2023
@DinoHad just to understand it better. If you use the @EricCornelson workaround the breakpoints are working fine for you now, right?
But you still see a weird message in the console, but this is not affecting the debugger experience, am I right?
LongJohnBlackbeard commentedon Jun 20, 2023
@EricCornelson dist.zip file worked for me. I am not getting any messages in the console though.
I did notice this in the debug console that was there before I did the dist.zip replacement, not sure if it is related:
DinoHad commentedon Jun 21, 2023
@LongJohnBlackbeard Yes, exactly.
ricardomomm commentedon Jun 22, 2023
The dist.zip worked for me as well, no error messages.
vsvsav commentedon Jun 25, 2023
Github, where is the button "I have the same bug" ? I have the same bug on all 17.6.* Pro, on 17.6.4 it works only after VS reinstalling and only the first time. If you reopen VS it won't work. MS does not have good (complex) unit tests.
puwalski commentedon Jun 28, 2023
Same problem in my VS but with Blazor WASM 6.0.5 and 6.0.19. The problem returns like a boomerang every few months and usually only disappears with the next Visual Studio update.
lewing commentedon Jul 10, 2023
7.0.11 and 6.0.21 shoud have have a fix for this.