Multiple Ninject 2.2 Bindings

I recently updated the ASP.NET MVC 3 application for Ninject 2.2.

I used to have the following interface for binding the implementation in the main application:

Bind(typeof(IMyInterface<>)).To(typeof(MyImplementation<>)).InRequestScope();

In addition, I had the following in another assembly downloaded by my main application:

var arg = new ConstructorArgument("info", "something");
Bind<IMyInterface<MyClass>>().To<MyImplementation<BlogComment>>().WithParameter(arg);

This worked well, and a more specific implementation was recognized (one with an argument). However, when I upgraded to Ninject 2.2, I received the following error:

Error activating IMyInterface{MyClass}
More than one matching bindings are available.
Activation path:
 2) Injection of dependency IMyInterface{MyClass} into parameter myParam of constructor of type SomeOtherClass
 1) Request for IMyInterface

Suggestions:
 1) Ensure that you have defined a binding for IMyInterface{MyClass} only once.

What has changed from 2.0 to 2.2, what causes this and is there any work?

+3
source share
1 answer

Ninject 2.2 , . 2.0 , , . , , .

, . , .

+5

Source: https://habr.com/ru/post/1792742/


All Articles