locked
C# Class in Blazor.Shared unknown in Blazor.Client RRS feed

  • Question

  • User1064403333 posted

    I created a new hosted Blazor WebAssembly solution which created 3 projects (targeting .NET 5 core)

    I created a new C# Class file in Blazor.Shared project but it is not visible i.e. it is not recognized in the Blazor.Client project (Pages/Index.razor file)

    I thought Classes were automatically shared and visible between Shared, Client and Server.

    What do I have to do for the client project to gain scope of the class? Or have I done something wrong

    The C# class is in Blazor.Shared namespace whilst the razor file is in Blazor.Client namespace. I am guessing this may have something to do with it.

    Monday, November 16, 2020 1:28 AM

Answers

  • User1064403333 posted

    For anyone else, in the razor page I needed to add

    @using BlazorAppName.Shared

    and I forgot to make the C# class public

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, November 16, 2020 2:56 AM