autofac / Autofac.ServiceFabric

Autofac integration for Azure Service Fabric. Provides service factory implementations for Actors, Stateful Services and Stateless Services.
MIT License
26 stars 27 forks source link

Service class constructor never invoked #44

Closed nhdmalik closed 6 years ago

nhdmalik commented 6 years ago

Hi, My stateless service class constructor never invoked and there is no exception. Here is my stateless service class:

    public interface IRemindersService : IService
    {
    }
    public class RemindersService : StatelessService, IRemindersService
    {
        private readonly IBackgroundService _weeklyReminderService;
        private readonly IBackgroundService _remindersProcessor;
        private readonly IReminderRepository _remindersRepository;

        public RemindersService(
            StatelessServiceContext context, 
            IReminderRepository remindersRepository, 
            IBackgroundService weeklyReminderService, 
            IBackgroundService remindersProcessor)
            : base(context)
        {
            _remindersProcessor = remindersProcessor;
            _remindersRepository = remindersRepository;
            _weeklyReminderService = weeklyReminderService;
        }        
    }

and program.cs

    private static void Main()
    {
            try
            {               
                var builder = new ContainerBuilder();

                builder.RegisterType<AppSettings>().As<IAppSettings>();
                builder.RegisterType<ReminderQueries>().As<IReminderQueries>();
                builder.RegisterType<SqlReminderRepository>().As<IReminderRepository>();
                builder.RegisterType<MessageSender>().As<IMessageSender>();
                builder.RegisterType<WeeklyReminderService>().As<IBackgroundService>();
                builder.RegisterType<RemindersProcessor>().As<IBackgroundService>();
                //builder.RegisterType<RemindersService>().As<IRemindersService>();

                builder.RegisterServiceFabricSupport();

                builder.RegisterStatelessService<RemindersService>("RemindersServiceType");

                using (builder.Build())
                {
                    ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(RemindersService).Name);
                    Thread.Sleep(Timeout.Infinite);
                }
    }
    catch (Exception e)
    {
           ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
           throw;
     }