Closed dgxhubbard closed 1 year ago
The Microsoft article and Code Maze use IStringLocalizer. I looked at the asp.net mvc article that just uses the @Resources generated by Resources.resx, and this works fine. So I not sure if IStringLocalizer is something old and will move on.
I am trying to find our if the Multilingual App Toolkit can be used in a webassembly? We have been using MAT for years in our desktop projects, and I tried to add MAT to a webassembly and everything was disabled in VS 2022. I added everything by hand, to
the webassembly (not shared project) and got it to compile. Then I used this article to add the needed string localizer.
I am getting an exception:
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100] Unhandled exception rendering component: Cannot provide a value for property 'localizer' on type 'BlazorApp2.Pages.License'. There is no registered service of type 'Microsoft.Extensions.Localization.IStringLocalizerg__Initialize|1(IServiceProvider serviceProvider, IComponent component)
at Microsoft.AspNetCore.Components.ComponentFactory.PerformPropertyInjection(IServiceProvider serviceProvider, IComponent instance)
at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateComponent(Type componentType)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.InstantiateChildComponentOnFrame(RenderTreeFrame& frame, 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[Gt.WebApi.Client.Locales.Resources]'. System.InvalidOperationException: Cannot provide a value for property 'localizer' on type 'BlazorApp2.Pages.License'. There is no registered service of type 'Microsoft.Extensions.Localization.IStringLocalizer
1[Gt.WebApi.Client.Locales.Resources]'. at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass7_0.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()