- ABP Framework version: v6.0.1
- UI type: Blazor Server
- DB provider: EF Core
- Exception message and stack trace:
System.ArgumentException: The type 'MyProject.Blazor.Components.Layout.MyMainHeaderToolbar' is not assignable to service 'Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.TopMenu.MainHeader.MainHeaderToolbar'.
at Autofac.Builder.RegistrationBuilder.CreateRegistration(Guid id, RegistrationData data, IInstanceActivator activator, IResolvePipelineBuilder pipelineBuilder, Service[] services, IComponentRegistration target)
at Autofac.Builder.RegistrationBuilder.CreateRegistration[TLimit,TActivatorData,TSingleRegistrationStyle](IRegistrationBuilder`3 builder)
at Autofac.Builder.RegistrationBuilder.RegisterSingleComponent[TLimit,TActivatorData,TSingleRegistrationStyle](IComponentRegistryBuilder cr, IRegistrationBuilder`3 builder)
at Autofac.ContainerBuilder.Build(IComponentRegistryBuilder componentRegistry, Boolean excludeDefaultModules)
at Autofac.ContainerBuilder.Build(ContainerBuildOptions options)
at Volo.Abp.Autofac.AbpAutofacServiceProviderFactory.CreateServiceProvider(ContainerBuilder containerBuilder)
at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter`1.CreateServiceProvider(Object containerBuilder)
at Microsoft.Extensions.Hosting.HostBuilder.CreateServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Microsoft.AspNetCore.Builder.WebApplicationBuilder.Build()
at MyProject.Blazor.Program.Main(String[] args) in D:\Projects\MyProject\src\MyProject.Blazor\Program.cs:line 65
- Steps to reproduce the issue:" I followed the instructions according to the documentation (https://docs.abp.io/en/commercial/latest/themes/lepton-x/blazor?UI=BlazorServer)
- Created Razor page MyMainHeaderToolbar.razor (the only content is @Name)
- Added MyMainHeaderToolbar.razor.cs with the following content:
using Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.TopMenu.MainHeader;
using Volo.Abp.DependencyInjection;
namespace MyProject.Blazor.Components.Layout
{
[ExposeServices(typeof(MainHeaderToolbar))]
[Dependency(ReplaceServices = true)]
public partial class MyMainHeaderToolbar
{
public string Name = "My Main Header Toolbar";
}
}
Does this still need to be registered somewhere?
6 Answer(s)
-
0
Would be great if I could get an answer on this topic. Thank you.
-
0
I am having the same issues. Any ideas?
-
0
Please make sure the namespaces. There are 2
MainHeaderToolbar
classes from 2 different namespacesVolo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.TopMenu.MainHeader.MainHeaderToolbar
Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.SideMenu.MainHeader.MainHeaderToolbar
-
0
@enisn: I use the TopMenu layout. Therefore the namespace should be correct.
I would have to test if the error still occurs with the new version... but I currently do not come to it, please leave the ticket still open.
-
0
It seems, you inherited from different
MainHeaderToolbar
and replaced differentMainHeaderToolbar
in the service collection.Can you check both MainHeaderToolbar in .razor file and .cs file. Both should be exact same type from the same namespace:
@inherits Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.TopMenu.MainHeader.MainHeaderToolbar
namespace MyProject.Blazor.Components.Layout { [ExposeServices(typeof(Volo.Abp.AspNetCore.Components.Web.LeptonXTheme.Components.ApplicationLayout.TopMenu.MainHeader.MainHeaderToolbar))] [Dependency(ReplaceServices = true)] public partial class MyMainHeaderToolbar { public string Name = "My Main Header Toolbar"; } }
-
0
Thank you for the explanation. This is how it worked. What was missing was the @inherits... in Razor file.
The documentation contains the sentence "Don't forget to remove repeated attributes from the razor page!". I must have deleted one line too much...