What is the constructor resolution order?

How does Castle Windsor determine which constructor to resolve when there are multiple constructors present?


All available constructors are modeled as candidates and basically a contest is run among them.

Each parameter in a constructor represents a dependency that can be either satisfied or not. For each constructor candidate, all dependencies are analyzed.

If a dependency can be satisfied, that's two points for the candidate. If it can't be satisfied, two points are subtracted from the candidate.

The constructor candidate with the most points wins and is chosen to instantiate the component.

The code for this algorithm is here.

Castle Windsor will use the constructor with the most parameters whose dependencies it can resolve.

When there are two constructors with the same number of parameters that Windsor can resolve, the behavior used to be seemingly arbitrary but may have been fixed.

See this post by Krzysztof Kozmic

Need Your Help

Decoding T-SQL CAST in C#/VB.NET

c# sql vb.net ascii hex

Recently our site has been deluged with the resurgence of the Asprox botnet SQL injection attack. Without going into details, the attack attempts to execute SQL code by encoding the T-SQL commands ...

iPhone web app startup screen

iphone web-applications fullscreen iphone-standalone-web-app

I'm working on an iPhone web app where I'm using the "apple-mobile-web-app-capable" meta tag to get "full screen mode". When I lauch the app it shows a picture of the page where I left of the last ...