Blazor不会引发未实现的异常

Blazor不会引发未实现的异常,blazor,blazor-webassembly,Blazor,Blazor Webassembly,我有一个简单的事件处理程序: 公共无效行ClickedTable行ClickEvents参数p { 抛出新的NotImplementedException; } 从该组件网调用的: 问题是blazor在方法被触发时不会抛出任何东西,这种行为正常吗?在回答您的问题时,这种行为正常吗?。不,我已经直接说了,因为昨天一些评论员错误地说,发布的内容没有直接回答问题,所以把它记下来了 下面是一个非常简单的razor标记页面,用于抛出错误并向您显示正常情况: @第页/例外第页 抛出异常 @代码{ 无效通过例

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

公共无效行ClickedTable行ClickEvents参数p { 抛出新的NotImplementedException; } 从该组件网调用的:


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

在回答您的问题时,这种行为正常吗?。不,我已经直接说了,因为昨天一些评论员错误地说,发布的内容没有直接回答问题,所以把它记下来了

下面是一个非常简单的razor标记页面,用于抛出错误并向您显示正常情况:

@第页/例外第页 抛出异常 @代码{ 无效通过例外 =>抛出新的NotImplementedException; } 当它在调试中以服务器模式运行时,抛出以下控制台输出

The method or operation is not implemented.

'iisexpress.exe' (CoreCLR: clrhost): Loaded 'C:\Program Files\dotnet\shared\Microsoft.NETCore.App\5.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\5.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\5.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\5.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)

不,这不正常。我认为根本没有调用您的方法,即事件正在触发。

您应该在控制台的日志上看到异常消息。这里有一个+1供您参考,不仅是为了给出一个明确的示例,也是因为我非常讨厌有人这样做:汉克斯,很高兴这也惹恼了别人!