I am trying to pass an interface and settings into a class while creating an instance of that class in startup.cs in .Net Core Project. I am using the below code to do so. I have some code written in the constructor of Student class but while starting the application the Code/Logic inside the constructor is not working. There is no error but the debug pointer is not hitting the constructor of Student class.
services.AddSingleton(c => new Student(settings, resourceSetting, c.GetService<IPersonService>()));
If I am using the below code then the code inside Student constructor is working fine.
Student studentHandler = new Student(settings, resourceSetting,);
services.AddSingleton<Student>(studentHandler);
But I need to pass Service interface in the constructor to do some work while starting the Project. Can anyone help me with what I am missing here?