Ninject with MVC4 - Binding all assemblies in bin folder
Asked Answered
P

1

5

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.

Paddy answered 1/1, 2014 at 20:15 Comment(0)
Q
10

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;
Questor answered 1/1, 2014 at 20:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.