fgilde / MudBlazor.Extensions

MudBlazor.Extensions from https://www.mudex.org is a small extension for MudBlazor from https://mudblazor.com
http://www.mudex.org
MIT License
245 stars 20 forks source link

[Bug]: Value cannot be null. (Parameter 'jsRuntime') #92

Closed gleIsocom closed 3 months ago

gleIsocom commented 5 months ago

Contact Details

No response

What happened?

I have created a Blazor WebAssembly testapp under net7, integrated MudBlazor and added MudBlazor.Extensions and want to display a sample dialog. No matter what I try, I always get the same error.

Expected Behavior

No Exceptions

Screenshots

image

Reproduction link

No response

What application type are you referring to?

WebAssembly

Custom Application Type

No response

MudBlazor.Extension Version

1.7.89

MudBlazor Version

6.20.0

What .net Version are you using?

.Net7

What browser are you using?

Chrome, Edge

Sample Solution

BlazorApp22.zip

Pull Request

No response

Code of Conduct

mreic commented 4 months ago

Have you tried passing jsRuntime as a parameter to the dialog?

First you inject jsRuntime:

[Inject] public IJSRuntime? js {get; set;}

Then use it in the DialogOptionsEx class:

 DialogOptionsEx options = new DialogOptionsEx() { JsRuntime = js};

 var dialog = await DialogService.ShowEx<SampleType>("DocTitle", parameters, options);

Edit: Maybe also naming the injected JsRuntime same as the Options-Variable is a problem?

fgilde commented 4 months ago

For an web assembly app you can still inject the IJSRuntime in your MainLayout for example and call

jsRuntime.InitializeMudBlazorExtensionsAsync()