I am working on an eShopOnContainers Project. I dont need Rabbitmq,docker and EventBus in this project so I removed it. But I am facing some errors related to Autofac dependencies.
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args)
.MigrateDbContext<OrderingContext>((context, services) =>
{
var env = services.GetService<IHostingEnvironment>();
var settings =
services.GetService<IOptions<OrderingSettings>>();
var logger =
services.GetService<ILogger<OrderingContextSeed>>();
new OrderingContextSeed()
.SeedAsync(context, env, settings, logger)
.Wait();
})
.MigrateDbContext<IntegrationEventLogContext>((_, __) => {
})
.Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseHealthChecks("/hc")
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((builderContext, config) =>
{
config.AddJsonFile("settings.json");
config.AddEnvironmentVariables();
})
.ConfigureLogging((hostingContext, builder) =>
{
builder.AddConfiguration(hostingContext.Configuration.GetSection("Logging"));
builder.AddConsole();
builder.AddDebug();
})
.UseApplicationInsights()
.Build();
}
This is the Error for Autofac dependency.The main Error is Autofac.Core.DependencyResolutionException.How to remove Autofac dependency error from eShop Project/Solution?
:
Autofac.Core.DependencyResolutionException
HResult=0x80131500
Message=An error occurred during the activation of a particular
registration. See the inner exception for details. Registration: Activator
= HostedServiceExecutor (ReflectionActivator), Services =
[Microsoft.AspNetCore.Hosting.Internal.HostedServiceExecutor], Lifetime =
Autofac.Core.Lifetime.RootScopeLifetime, Sharing = Shared, Ownership =
OwnedByLifetimeScope
Source=Autofac
StackTrace:
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1
parameters)
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id,
Func`1 creator)
at Autofac.Core.Resolving.InstanceLookup.Execute()
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance
(ISharingLifetimeScope currentOperationScope, IComponentRegistration
registration, IEnumerable`1 parameters)
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration
registration, IEnumerable`1 parameters)
at Autofac.ResolutionExtensions.TryResolveService(IComponentContext
context, Service service, IEnumerable`1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveService(IComponentContext
context, Service service, IEnumerable`1 parameters)
at
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.
GetRequiredService(IServiceProvider provider, Type serviceType)
at
Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.
GetReq uiredService[T] (IServiceProvider provider)
at Microsoft.AspNetCore.Hosting.Internal.WebHost.
<StartAsync>d__26.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.
HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.
<RunAsync>d__5.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at
System.Runtime.CompilerServices.TaskAwaiter
.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.
<RunAsync>d__4.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter
.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
at Program.Main(String[] args) in
Inner Exception 1:
DependencyResolutionException: An error occurred during the activation of a
particular registration.
See the inner exception for details. Registration: Activator =
IHostedService[] (DelegateActivator),
Services = [System.Collections.Generic.IEnumerable`1[
[Microsoft.Extensions.Hosting.IHostedService,
Microsoft.Extensions.Hosting.Abstractions, Version=2.0.0.0,
Culture=neutral,
PublicKeyToken=adb9793829ddae60]]], Lifetime =
Autofac.Core.Lifetime.CurrentScopeLifetime, Sharing = None, Ownership =
ExternallyOwned
Inner Exception 2:
DependencyResolutionException: An error occurred during the activation of
a particular registration.
See the inner exception for details. Registration: Activator =
GracePeriodManagerService (ReflectionActivator),
Services = [Microsoft.Extensions.Hosting.IHostedService], Lifetime =
Autofac.Core.Lifetime.RootScopeLifetime,
Sharing = Shared, Ownership = OwnedByLifetimeScope
Inner Exception 3:
DependencyResolutionException: None of the constructors found with
'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type
'Ordering.API.Infrastructure.HostedServices.GracePeriodManagerService' can
be invoked with the available services and parameters:
Cannot resolve parameter 'BuildingBlocks.EventBus.Abstractions.IEventBus
eventBus' of constructor 'Void
.ctor(Microsoft.Extensions.Options.IOptions`1[
Services.Ordering.API.OrderingSettings],
BuildingBlocks.EventBus.Abstractions.IEventBus,
Microsoft.Extensions.Logging.ILogger`1[Ordering.API.Infrastructure
.HostedServices.GracePeriodManagerService])'.
This is the Error for Autofac dependency.The main Error is Autofac.Core.DependencyResolutionException.How to remove Autofac dependency error from eShop Project/Solution?
User contributions licensed under CC BY-SA 3.0