1

I have followed the installation instructions from https://www.matblazor.com/.

1.Add @using MatBlazor in main _Imports.razor

@using MatBlazor

2.Add script section to index.html (head section)

<script src="_content/MatBlazor/dist/matBlazor.js"></script>
<link href="_content/MatBlazor/dist/matBlazor.css" rel="stylesheet" />

3.Add registration of service to Startup.cs

services.AddMatBlazor();

4.Add MatPortalHost component to root component (App.razor) for some services like MatDialogService, MatPortalService

<MatPortalHost></MatPortalHost>

Error when starting:

crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Cannot provide a value for property 'PortalService' on type 'MatBlazor.MatPortalHost'. There is no registered service of type 'MatBlazor.IMatPortalService'. System.InvalidOperationException: Cannot provide a value for property 'PortalService' on type 'MatBlazor.MatPortalHost'. There is no registered service of type 'MatBlazor.IMatPortalService'.

1 Answer 1

2

Turns out 3.Add registration of service to Startup.cs is not the same for Blazor WebAssembly App.

Add builder.Services.AddMatBlazor(); to Program.cs Main method in the BlazorWebAssemblyApp.Client and then everything should work. No need to edit anything in BlazorWebAssemblyApp.Server or BlazorWebAssemblyApp.Shared.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, just what I needed as well for my Blazor WASM app!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.