Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ninject with MVC4 - Binding all assemblies in bin folder

I am following this article to create a pluggable MVC application. Once ninject has been installed, it says to add this:

var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"); 
kernel.Bind(a => a.FromAssembliesInPath(path).SelectAllClasses().BindDefaultInterface());

to the RegisterServices method in the NinjectWebCommon.cs file, however, when I do this, I get the following error:

Cannot convert lambda expression to type 'System.Type[]' because it is not a delegate type.

This is fair enough, I understand the error but I'm not sure how to get around it. Has something changed in ninject to cause this error? I would appreciate some advice on how to proceed.

like image 957
webnoob Avatar asked Jan 01 '14 20:01

webnoob


Video Answer


1 Answers

The Bind method with the signature Bind(this IBindingRoot kernel, Action<IFromSyntax> configure) - which was used in the article - is declared as an extension method in the Ninject.Extensions.Conventions namespace's ExtensionsForIKernel class inside the ninject.extensions.convention plugin.

So you are missing the right using statement.

Add this line to the NinjectWebCommon.cs file to make your code compile:

using Ninject.Extensions.Conventions;
like image 102
nemesv Avatar answered Sep 20 '22 13:09

nemesv