Solarion
Honorary Master
- Joined
- Nov 14, 2012
- Messages
- 28,050
- Reaction score
- 17,804
hi guys. I have a problem with an old legacy project that has landed across my desk. It is in .NET 5.6.
In trying to fix their dependency hell I have created a fresh project to try to understand how Ninject works. I have a simple SQLDBClass, a GenericRepository and a Service. This is the service constructor.
On the ninject side in the NinjectWebCommon class, my respository binds perfectly
But come time to the service in say a HomeController it all goes to pieces. I think it has something to do with the constructor in ReservationService.
kernel.Bind(typeof(lReservationService)).To(typeof(ReservationService));
I get this error: : 'Error activating IRepository{ReservationType} No matching bindings are available, and the type is not self-bindable. Activation path:
I've been staring at this all weekend to no avail. If anyone has any ideas on this please share them!
In trying to fix their dependency hell I have created a fresh project to try to understand how Ninject works. I have a simple SQLDBClass, a GenericRepository and a Service. This is the service constructor.
Code:
public class ReservationService : IReservationService
{
private readonly IRepository<ReservationType> _context;
public ReservationService(IRepository<ReservationType> context)
{
_context = context;
}
}
On the ninject side in the NinjectWebCommon class, my respository binds perfectly
Code:
kernel.Bind(typeof(IRepository<>)).To(typeof(Repository<>));
kernel.Bind(typeof(IRepository<ReservationType>)).To(typeof(ReservationType));
But come time to the service in say a HomeController it all goes to pieces. I think it has something to do with the constructor in ReservationService.
kernel.Bind(typeof(lReservationService)).To(typeof(ReservationService));
I get this error: : 'Error activating IRepository{ReservationType} No matching bindings are available, and the type is not self-bindable. Activation path:
I've been staring at this all weekend to no avail. If anyone has any ideas on this please share them!