You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fix For: Missing LibraryConfiguring Injection in DesignToken.razor.cs #2425
This issue occurs exclusively in version 4.9.2, downgrading to 4.9.1 resolves the issue.
When injecting any design token and calling .SetValue() with any element reference, the DesignToken class fails to inject the registered LibraryConfiguration causing an Object reference not set to an instance of an object exception to be thrown inside UrlFormatterExtensions.cs.
💻 Repro or Code Sample
Component:
@usingMicrosoft.FluentUI.AspNetCore.Components.DesignTokens
<div class="container"><FluentTextField @ref="Test"@bind-Value=Title></FluentTextField></div>@code{[Parameter,EditorRequired]public string Title {get;set;}=null!;
FluentTextField Test;[Inject]private Density _density {get;set;}=default!;protectedoverrideasyncTaskOnAfterRenderAsync(boolfirstRender){if(firstRender){await_density.SetValueFor(Test.Element,10);StateHasChanged();}}}
I went ahead and checked out this repository to see if I could find the issue and I was able to locate the issue and confirm the fix locally.
It appears there was an existing DI constructor in DesignToken which set the IJSRuntime, but not the LibraryConfiguration which was introduced in 4.9.2.
I modified the constructor for DesignToken as well as the DesignTokenGenerator to add the DI for LibraryConfiguration for all design tokens:
changed the title [-]fix: Missing LibraryConfiguring Injection in DesignToken.razor.cs[/-][+]Fix For: Missing LibraryConfiguring Injection in DesignToken.razor.cs[/+]on Jul 21, 2024
Activity
TimonFeldmann commentedon Jul 21, 2024
I went ahead and checked out this repository to see if I could find the issue and I was able to locate the issue and confirm the fix locally.
It appears there was an existing DI constructor in
DesignTokenwhich set theIJSRuntime, but not theLibraryConfigurationwhich was introduced in 4.9.2.I modified the constructor for
DesignTokenas well as theDesignTokenGeneratorto add the DI forLibraryConfigurationfor all design tokens:Fix is included in #2426
[-]fix: Missing LibraryConfiguring Injection in DesignToken.razor.cs[/-][+]Fix For: Missing LibraryConfiguring Injection in DesignToken.razor.cs[/+]marqdouj commentedon Apr 5, 2025
fwiw, I just tried creating a WPF/Blazor Hybrid
I figured I would try and replace the bootstrap with FluentUI-Blazor.
When I did, the app would not run and I got the 'LibraryConfiguration' error.
So I added the fix to the MainWindow constructor and it worked:
var serviceCollection = new ServiceCollection(); serviceCollection.AddWpfBlazorWebView(); serviceCollection.AddSingleton(new LibraryConfiguration() { CollocatedJavaScriptQueryString = null, }); Resources.Add("services", serviceCollection.BuildServiceProvider());