Skip to content

.NET 6 Preview 4 Blazor - inheriting RouteView causes runtime exception #33022

@Jackwar

Description

@Jackwar

Describe the bug

Inheriting RouteView in a class and replacing RouteView with the inherited class in App.razor causes a runtime exception on startup when using AOT. The error claims that the parameter 'RouteData' is not public.

This scenario still works using the interpreter instead of AOT.

To Reproduce

Inherit RouteView in a class.
public class TestRouteView : RouteView {}

Replace RouteView in App.razor with the custom class.
<Found Context="routeData"> <TestRouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> </Found>

Compile Blazor for AOT. Run the compiled app to cause a runtime exception.

A repo to reproduce is here.

Exceptions (if any)

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: The type 'RouteViewAOTTest.TestRouteView' declares a parameter matching the name 'RouteData' that is not public. Parameters must be public.
System.InvalidOperationException: The type 'RouteViewAOTTest.TestRouteView' declares a parameter matching the name 'RouteData' that is not public. Parameters must be public.

Further technical details

  • ASP.NET Core 6 Preview 4
  • Include the output of dotnet --info

.NET SDK (reflecting any global.json):
Version: 6.0.100-preview.4.21255.9
Commit: 950e4949a7

Runtime Environment:
OS Name: Windows
OS Version: 10.0.19042
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\6.0.100-preview.4.21255.9\

Host (useful for support):
Version: 6.0.0-preview.4.21253.7
Commit: bfd6048a60

.NET SDKs installed:
3.1.202 [C:\Program Files\dotnet\sdk]
3.1.404 [C:\Program Files\dotnet\sdk]
5.0.201 [C:\Program Files\dotnet\sdk]
5.0.203 [C:\Program Files\dotnet\sdk]
6.0.100-preview.4.21255.9 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 6.0.0-preview.4.21253.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.0-preview.4.21253.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.0-preview.4.21254.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

To install additional .NET runtimes or SDKs:
https://aka.ms/dotnet-download

  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version

Microsoft Visual Studio Community 2019
Version 16.9.6

  • Browsers Tested On
    Google Chrome 91.0.4472.77
    Firefox 88.0.1
    Microsoft Edge 90.0.818.66

Metadata

Metadata

Assignees

No one assigned

    Labels

    ✔️ Resolution: DuplicateResolved as a duplicate of another issueExternalThis is an issue in a component not contained in this repository. It is open for tracking purposes.Status: Resolvedarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.feature-blazor-wasmThis issue is related to and / or impacts Blazor WebAssembly

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions