I am using Blazor Studio to design a page. After a I hooked up a class to persist the results, the page no longer loads in Blazor Studio. Code and analysis log is below.
Any ideas how to fix? Many thanks.
CODE
@ page "/clientedit/{clientId:int?}"
@ using Sibs.Shared.Interface;
@ using Sibs.Shared.Model;
@ inject IClientService ClientService
@ inject NavigationManager Navigation
@ using Radzen
<RadzenTextBox @bind-Value="client.Person1Name" Name="Person1Name" Placeholder="Person 1 Name" Style="width: 100%" />
<RadzenRequiredValidator Component="Person1Name" Text="Person 1 Name is required" />
<br /><br />
<RadzenTextBox @bind-Value="client.Person1ShortName" Name="Person1ShortName" Placeholder="Person 1 Short Name" Style="width: 100%" />
<RadzenRequiredValidator Component="Person1ShortName" Text="Person 1 Short Name is required" />
<br /><br />
<RadzenDatePicker @bind-Value="client.Person1Birthday" Name="Person1Birthday" Style="width: 100%" />
<RadzenRequiredValidator Component="Person1Birthday" Text="Person 1 Birthday is required" />
<br /><br />
<RadzenTextBox @bind-Value="client.Person2Name" Name="Person2Name" Placeholder="Person 2 Name" Style="width: 100%" />
<br /><br />
<RadzenTextBox @bind-Value="client.Person2ShortName" Name="Person2ShortName" Placeholder="Person 2 Short Name" Style="width: 100%" />
<br /><br />
<RadzenDatePicker @bind-Value="client.Person2Birthday" Name="Person2Birthday" Style="width: 100%" />
<br /><br />
<RadzenButton ButtonType="ButtonType.Submit" Text="@(client.Id == 0 ? "Add Client" : "Save Changes")" Style="margin-right: 20px" />
<RadzenButton ButtonType="ButtonType.Button" Text="Cancel" Click="Cancel" Style="margin-right: 20px" />
</RadzenFieldset>
</div>
@code {
[Parameter] public int? ClientId { get; set; }
private Client client = new Client();
protected override async Task OnInitializedAsync()
{
if (ClientId.HasValue && ClientId.Value > 0)
{
var clients = ClientService.GetClients();
client = clients.FirstOrDefault(c => c.Id == ClientId.Value) ?? new Client();
}
}
private async Task HandleValidSubmit()
{
if (client.Id == 0)
{
client.LastUpdated = DateTime.Now;
await ClientService.AddClientAsync(client);
}
else
{
client.LastUpdated = DateTime.Now;
await ClientService.UpdateClientAsync(client);
}
Navigation.NavigateTo("/clients");
}
private void Cancel()
{
Navigation.NavigateTo("/clients");
}
}
ANALYSIS LOG
Analyzing c:\src\sibs4\Client\Sibs.ClientApp.csproj ...
Analyzing c:\src\sibs4\Sibs.Shared\Sibs.Shared.csproj ...
Done.
Analyzing c:\src\sibs4\Client\Sibs.ClientApp.csproj ...
Rendering Layout\MainLayout.razor ... OK.
Rendering Pages\ClientEdit.razor ... FAIL.
System.InvalidOperationException: Cannot provide a value for property 'ClientService' on type 'Sibs.ClientApp.Pages.ClientEdit'. There is no registered service of type 'Sibs.Shared.Interface.IClientService'.
at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable1 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, ArrayRange1 newTree) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue() --- End of stack trace from previous location --- at Radzen.Server.HtmlRenderer.HandleException(Exception exception) at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue() at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment) at Radzen.Server.Router.Render(Type layout, Type component, Boolean renderLayout) at Radzen.Server.StaticRouter.SetParametersAsync(ParameterView parameters) at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters) --- End of stack trace from previous location --- at Radzen.Server.HtmlRenderer.HandleException(Exception exception) at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters) at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(Int32 componentId, ParameterView initialParameters) at Radzen.Server.HtmlRenderer.CreateInitialRenderAsync(Type componentType, ParameterView initialParameters) at Radzen.Server.HtmlRenderer.RenderComponentAsync(Type componentType, ParameterView initialParameters) at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c__11
1.<b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
at Radzen.Server.ProjectServer.Crawl(String fileName, String source)
at Radzen.Server.ProjectAnalyzer.AnalyzeFile(ProjectContext projectContext, SolutionFacade solutionFacade, String razorFile, Boolean parallel, Boolean all, CancellationToken token)
Rendering Pages\ClientList.razor ... FAIL.
System.InvalidOperationException: Cannot provide a value for property 'ClientService' on type 'Sibs.ClientApp.Pages.ClientList'. There is no registered service of type 'Sibs.Shared.Interface.IClientService'.
at Microsoft.AspNetCore.Components.ComponentFactory.<>c__DisplayClass9_0.g__Initialize|1(IServiceProvider serviceProvider, IComponent component)
at Microsoft.AspNetCore.Components.ComponentFactory.InstantiateComponent(IServiceProvider serviceProvider, Type componentType, IComponentRenderMode callerSpecifiedRenderMode, Nullable1 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, ArrayRange1 newTree) at Microsoft.AspNetCore.Components.Rendering.ComponentState.RenderIntoBatch(RenderBatchBuilder batchBuilder, RenderFragment renderFragment, Exception& renderFragmentException) at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue() --- End of stack trace from previous location --- at Radzen.Server.HtmlRenderer.HandleException(Exception exception) at Microsoft.AspNetCore.Components.RenderTree.Renderer.ProcessRenderQueue() at Microsoft.AspNetCore.Components.RenderTree.Renderer.AddToRenderQueue(Int32 componentId, RenderFragment renderFragment) at Radzen.Server.Router.Render(Type layout, Type component, Boolean renderLayout) at Radzen.Server.StaticRouter.SetParametersAsync(ParameterView parameters) at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters) --- End of stack trace from previous location --- at Radzen.Server.HtmlRenderer.HandleException(Exception exception) at Microsoft.AspNetCore.Components.Rendering.ComponentState.SetDirectParameters(ParameterView parameters) at Microsoft.AspNetCore.Components.RenderTree.Renderer.RenderRootComponentAsync(Int32 componentId, ParameterView initialParameters) at Radzen.Server.HtmlRenderer.CreateInitialRenderAsync(Type componentType, ParameterView initialParameters) at Radzen.Server.HtmlRenderer.RenderComponentAsync(Type componentType, ParameterView initialParameters) at Microsoft.AspNetCore.Components.Rendering.RendererSynchronizationContext.<>c__11
1.<b__11_0>d.MoveNext()
--- End of stack trace from previous location ---
at Radzen.Server.ProjectServer.Crawl(String fileName, String source)
at Radzen.Server.ProjectAnalyzer.AnalyzeFile(ProjectContext projectContext, SolutionFacade solutionFacade, String razorFile, Boolean parallel, Boolean all, CancellationToken token)
Rendering Pages\Index.razor ... OK.
Done.
Finished with errors.