Blazor 不会抛出未实现的异常

Blazor does not throw a not implemented Exception

我有这个简单的事件处理程序:

public void RowClicked(TableRowClickEventArgs<Prods> p)
{
    throw new NotImplementedException();            
}

从这个组件网络调用:

<MudTable Items="@Products" OnRowClick="@RowClicked" >
</MudTable>

问题是当方法被触发时 blazor 没有抛出任何东西,这种行为正常吗?

回答你的问题“这种行为正常吗?”。不。(我已经直接说明了这一点,因为一些评论者昨天(错误地)指出发布的内容没有直接回答问题,因此将其记下来!!!)。

这是一个非常简单的剃刀标记页面,用于抛出错误并向您展示什么是正常的:

@page "/exceptionpage"

<div class="m-3 p-3">
    <button class="btn btn-danger ml-2" @onclick="() => ThrowException()">Throw Exception</button>
</div>

@code {
    void ThrowException()
        => throw new NotImplementedException();
}

当它处于 运行 调试的服务器模式时,抛出以下控制台输出

The method or operation is not implemented.

'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App.0.5\System.Diagnostics.StackTrace.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App.0.5\System.Reflection.Metadata.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App.0.5\System.Collections.Immutable.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App.0.5\System.IO.MemoryMappedFiles.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.
Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer: Warning: Unhandled exception rendering component: The method or operation is not implemented.

System.NotImplementedException: The method or operation is not implemented.
   at Blazor.Starter.Pages.Index.ThrowException() in D:\Shaun\source\repos\Blazor.Starter\Blazor.Starter\Pages\Index.razor:line 61
   at Blazor.Starter.Pages.Index.<BuildRenderTree>b__0_4() in D:\Shaun\source\repos\Blazor.Starter\Blazor.Starter\Pages\Index.razor:line 18
   at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync[T](MulticastDelegate delegate, T arg)
   at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, Object arg)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)
Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost: Error: Unhandled exception in circuit 'oiyAzPmWxjSN4vTZ-FvyxNu299jz_TxRMituQ8soZC0'.

System.NotImplementedException: The method or operation is not implemented.
   at Blazor.Starter.Pages.Index.ThrowException() in D:\Shaun\source\repos\Blazor.Starter\Blazor.Starter\Pages\Index.razor:line 61
   at Blazor.Starter.Pages.Index.<BuildRenderTree>b__0_4() in D:\Shaun\source\repos\Blazor.Starter\Blazor.Starter\Pages\Index.razor:line 18
   at Microsoft.AspNetCore.Components.EventCallbackWorkItem.InvokeAsync[T](MulticastDelegate delegate, T arg)
   at Microsoft.AspNetCore.Components.ComponentBase.Microsoft.AspNetCore.Components.IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, Object arg)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.DispatchEventAsync(UInt64 eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs)

不,这不正常。我根本不相信您的方法正在被调用,即事件正在触发。