Consider this code:
public class IocConfig
{
protected static StandardKernel Kernel { get; set; }
public static void RegisterIoc(HttpConfiguration config)
{
using (IKernel kernel = new StandardKernel())
{
RegisterDependency();
config.DependencyResolver = new NinjectDependencyResolver(kernel);
}
}
public static void RegisterIoc()
{
RegisterDependency();
}
private static void RegisterDependency()
{
if (Kernel == null)
{
Kernel = new StandardKernel();
}
Kernel.Bind<CallCenterLogger>().ToSelf().Intercept().With(new TimingInterceptor());
}
public static T GetType<T>()
{
RegisterDependency();
return Kernel.Get<T>();
}
}
in this line:
Kernel.Bind<CallCenterLogger>().ToSelf().Intercept().With(new TimingInterceptor());
I get this error:
Error loading Ninject component IAdviceFactory
No such component has been registered in the kernel's component container.
Suggestions:
1) If you have created a custom subclass for KernelBase, ensure that you have properly
implemented the AddComponents() method.
2) Ensure that you have not removed the component from the container via a call to RemoveAll().
3) Ensure you have not accidentally created more than one kernel.
How can solve it?