-
-
Notifications
You must be signed in to change notification settings - Fork 363
Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
因为是延迟加载, 不能一定保证json完全合规. json是按需载入的,如果其中一个文件格式有问题的话,整个系统就直接崩了.
要在哪里处理这个异常比较理想呢?
Expected Behavior
是不是可以先判断是否合法的json再载入
Interactive render mode
Interactive Server (Interactive server-side rendering (interactive SSR) using Blazor Server)
Steps To Reproduce
复现工程
- 新建bb模板工程
- 加入语言选择功能
- Locales 英文文件json格式加点错误字符

- 运行工程
- 切换到英文语言
- 崩溃
- 重新运行工程,使用的是上次的语言设置, 持续崩溃
- 这个问题的难点在于, 只在对应资源出问题才会卡进bug, 比如例子工程,中文切英文, 在table和花名册就没问题, 回到首页才会崩溃. 万一有一行没处理好或者资源文件是外部附加的,就有点头大
fail: BootstrapBlazor.Components.ErrorLogger[0]
BootstrapBlazorErrorBoundary OnErrorAsync log this error
System.ArgumentNullException: Value cannot be null. (Parameter 'value')
at System.ArgumentNullException.Throw(String paramName)
at System.ArgumentNullException.ThrowIfNull(Object argument, String paramName)
at Microsoft.Extensions.Localization.LocalizedString..ctor(String name, String value, Boolean resourceNotFound, String searchedLocation)
at BootstrapBlazor.Components.CacheManager.<>c__DisplayClass25_0.<GetJsonStringByTypeName>b__4(IConfigurationSection kv)
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Func`2 predicate, Boolean& found)
at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source, Func`2 predicate)
at BootstrapBlazor.Components.JsonStringLocalizer.<>c__DisplayClass15_0.<GetValueFromCache>g__GetLocalizedString|0()
at BootstrapBlazor.Components.JsonStringLocalizer.GetValueFromCache(IEnumerable`1 localizerStrings, String name)
at BootstrapBlazor.Components.JsonStringLocalizer.<GetStringSafely>g__GetStringSafelyFromJson|14_1(String name)
at BootstrapBlazor.Components.JsonStringLocalizer.GetStringSafely(String name)
at BootstrapBlazor.Components.JsonStringLocalizer.get_Item(String name)
at BootstrapBlazorApp.Server.Components.Pages.Index.BuildRenderTree(RenderTreeBuilder __builder)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException)
Exceptions (if any)
.NET Version
NET9.0
Anything else?
No response
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working