-
Notifications
You must be signed in to change notification settings - Fork 35
Manually Loading the Factory Extension into the Ninject Kernel
Floyd May edited this page May 8, 2015
·
1 revision
In some cases, you can't rely on Ninject's automatic plugin loading (e.g. Silverlight). In that case, you must load the Factory extension's module manually. Wherever you are instantiating your Kernel
, add an instance of Ninject.Extensions.Factory.FuncModule
to the array of modules to load. For instance:
var kernel = new StandardKernel(
new MainModule(), // defined by your app
new FuncModule() // assuming you have "using Ninject.Extensions.Factory;" at the top of your file
);
If the module isn't loaded, you can still create factory bindings:
Bind<ISomeFactory>().ToFactory();
However, these bindings will fail at runtime with an exception that looks like this:
Error activating IInterceptor using conditional implicit self-binding of IInterceptor
Provider returned null.
Activation path:
3) Injection of dependency IInterceptor into parameter of constructor of type ISomeFactoryProxy
2) Injection of dependency ISomeFactory into parameter factory of constructor of type SomeType
1) Request for SomeType
Suggestions:
1) Ensure that the provider handles creation requests properly.