-
Notifications
You must be signed in to change notification settings - Fork 528
Changes in Ninject 3
chafey edited this page Feb 15, 2012
·
10 revisions
Link to thread announcing Ninject 3 RC Availability
- New Features and changes of Ninject 3.0
- Ninject.Extensions.Factory introduction
- Ninject constructor selection preview
Ninject 2.2 has an issue where the constructor it selects can change. Here is an example:
class Foo {
Foo() {}
Foo(Bar bar) {}
}
kernel.Get<Foo>(); // The Foo() constructor is called by Ninject 2.2 the first time Foo is resolved
kernel.Get<Bar>();
kernel.Get<Foo>(); // The Foo(Bar bar) constructor is called since Ninject 2.2 now knows about Bar.
To resolve this issue, Ninject 3 will now choose the constructor with the most arguments it knows how to create:
class Foo {
Foo() {}
Foo(Bar bar) {}
}
kernel.Get<Foo>(); // The Foo(Bar bar) constructor is called by Ninject 3.0
kernel.Get<Bar>();
kernel.Get<Foo>(); // The Foo(Bar bar) constructor is called by Ninject 3.0
This means the implicit bindings like self bindable types and closed generic types when there is only an open generic implementation should be included. Bottom line – if you are upgrading to Ninject 3.0 from Ninject 2.2, check your bound types to make sure the correct constructor is used!
Go back to the Home page or the Table of Contents
Continue reading: Why Use Ninject?
Licensed under Apache 2 License
Contents
- Home
- Why Use Ninject
- Getting Started
- Dependency Injection By Hand
- Dependency Injection With Ninject
- Injection Patterns
- Multi Injection
- Object Scopes
- Modules and the Kernel
- Providers, Factory Methods and the Activation Context
- The Activation Process
- How Injection Works
- Contextual Binding
- Conventions-Based Binding