---
# System prepended metadata

title: FluentNumberField を WebAssembly で使用すると `There is no registered service of type 'Microsoft.FluentUI.AspNetCore.Components
tags: [FluentNumberField, Fluent UI Blazor, Fluent, エラー, LibraryConfiguration, Blazor]

---

---
lang: ja-jp
breaks: true
---
# FluentNumberField を WebAssembly で使用すると `There is no registered service of type 'Microsoft.FluentUI.AspNetCore.Components.LibraryConfiguration'.` とエラーが発生する。  2024-01-19

```log=
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
      Unhandled exception rendering component: Cannot provide a value for property 'LibraryConfiguration' on type 'Microsoft.FluentUI.AspNetCore.Components.FluentInputLabel'. There is no registered service of type 'Microsoft.FluentUI.AspNetCore.Components.LibraryConfiguration'.
System.InvalidOperationException: Cannot provide a value for property 'LibraryConfiguration' on type 'Microsoft.FluentUI.AspNetCore.Components.FluentInputLabel'. There is no registered service of type 'Microsoft.FluentUI.AspNetCore.Components.LibraryConfiguration'.
   at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.<CreatePropertyInjector>g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
   at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable`1 parentComponentId)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame[] frames, Int32 frameIndex, Int32 parentComponentId)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewComponentFrame(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InitializeNewSubtree(DiffContext& diffContext, Int32 frameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.InsertNewFrame(DiffContext& diffContext, Int32 newFrameIndex)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.AppendDiffEntriesForRange(DiffContext& diffContext, Int32 oldStartIndex, Int32 oldEndIndexExcl, Int32 newStartIndex, Int32 newEndIndexExcl)
   at Microsoft.AspNetCore.Components.RenderTree.RenderTreeDiffBuilder.ComputeDiff(Renderer renderer, RenderBatchBuilder batchBuilder, Int32 componentId, ArrayRange`1 oldTree, ArrayRange`1 newTree)
   at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderInExistingBatch(RenderQueueEntry renderQueueEntry)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue()
```

## プロジェクトテンプレート

![image](https://hackmd.io/_uploads/r1kA7BwY6.png)

![image](https://hackmd.io/_uploads/r1iJ4SvY6.png)


## クライアント側プロジェクト（XXXX.Client） の Program.cs に以下を追加すると動作する。

```csharp=
builder.Services.AddScoped<Microsoft.FluentUI.AspNetCore.Components.LibraryConfiguration>();
```

全体は以下のようになる
```csharp=
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;

var builder = WebAssemblyHostBuilder.CreateDefault(args);

builder.Services.AddScoped<Microsoft.FluentUI.AspNetCore.Components.LibraryConfiguration>();

await builder.Build().RunAsync();
```

###### tags: `Fluent UI Blazor` `Blazor` `Fluent` `FluentNumberField` `エラー` `LibraryConfiguration`
