Activities of "LuisSpotOn"

Hello,

I am building a background worker by following the docs and for some reason i can't inject any repository. When i try to inject the IUserRepository i get the exception on this message and when i try to inject a repository created with ABP Suite i get that the DbContext has already been disposed.

If you're creating a bug/problem report, please include followings:

  • ABP Framework version: v4.4.2

  • UI type: MVC

  • DB provider: EF Core

  • Tiered (MVC) or Identity Server Separated (Angular): no

  • Exception message and stack trace:

Autofac.Core.Registration.ComponentNotRegisteredException: The requested service 'Volo.Abp.Users.IUserRepository`1[[Test.Users.AppUser, Test.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]' has not been registered. To avoid this exception, either register a component to provide the service, check for service registration using IsRegistered(), or use the ResolveOptional() method to resolve an optional dependency.
   at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType, IEnumerable`1 parameters)
   at Autofac.ResolutionExtensions.Resolve(IComponentContext context, Type serviceType)
   at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetRequiredService(Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
   at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
   at Test.BackgroundWorkers.ExportInvoiceItemsToStripeBackgroundWorker.DoWorkAsync(PeriodicBackgroundWorkerContext workerContext) in C:\Dev\Test\src\Test.Application\BackgroundWorkers\ExportInvoiceItemsToStripeBackgroundWorker.cs:line 23
  • Steps to reproduce the issue:"
public class TestBackgroundWorker : AsyncPeriodicBackgroundWorkerBase
{
 public TestBackgroundWorker(AbpAsyncTimer timer, IServiceScopeFactory serviceScopeFactory) : base(timer, serviceScopeFactory)
 {
    Timer.Period = (int) TimeSpan.FromMinutes(1).TotalMilliseconds;
 }

 protected override async Task DoWorkAsync(PeriodicBackgroundWorkerContext workerContext)
 {
    var userRepository = workerContext.ServiceProvider.GetRequiredService<IUserRepository<AppUser>>();
 }
}
Showing 1 to 1 of 1 entries
Made with ❤️ on ABP v9.1.0-preview. Updated on December 26, 2024, 06:07