I’ve run into an issue several times recently while working in Blazor where I’ll innocently try and run the application after some minor changes, only to be hit by a wall of errors seemingly out of nowhere:
ExamplePage.razor.cs(7, 29): [CS0115] 'ExamplePage.OnInitializedAsync()': no suitable method found to override
ExamplePage.razor.cs(12, 29): [CS0115] 'ExamplePage.OnAfterRenderAsync(bool)': no suitable method found to override
ExamplePage.razor.cs(17, 29): [CS0115] 'ExamplePage.OnParametersSetAsync()': no suitable method found to override
ExamplePage.razor.cs(22, 26): [CS0115] 'ExamplePage.SetParametersAsync(ParameterView)': no suitable method found to override
All of a sudden every single Razor component lifecycle function throughout the application is exploding and I’m left wondering how I managed to break things so spectacularly.
My approach to fixing this historically was:
- Take a look at my local changes in Git
- Try to tweak things to get it working again
- Fail
- Roll back everything and re-implement the change
It was frustrating and had wasted enough of my time over the past few months that I decided that I was going to figure it out once and for all, by gum.
Note: If you’re in a hurry the fix is quick and simple, so feel free to jump straight down to that section to skip my self-indulgent waffling.
Continue reading ““No suitable method found to override” error in Blazor/Razor pages”