No parameterless constructor exception, Greediest Constructor and DefaultConstructor-attribute

You propably have pump into IoC framework (StructureMap) problem "No parameterless constructor" but are you familiar with StructureMap constructor selection, greediest constructor rule, default constructor attribute and good practices of implementing multiple constructors. You probably have seen this YSOD-screen before and it actually says that my StartPageController-does not have parameterless constructor.  In this case the original problem had happen way before this MissingMethodException was thrown. The original exception was catch and written down into log-file and it hides the original exception. That's definitely a problem but in this case there was a good reason for it and it's not the original problem. No parameterless constructor Log file tells that something has broke the StructureMap and that's why none of the future StructureMap requests can be processed. In this case the problem was simple "Required primitive dependency is not explicitly defined". So there was string parameter in the constructor which StructureMap try to use. StructureMap selects the constructor which had the most parameters (Greediest Constructor -rule). One simple solution to primitive type constructor parameter is to mark constructor with DefaultConstructor-attribute and initial the default values in runtime. Note that the other constructor has it's own purpose also. DefaultConstructor This way your you don't have to mind what type of constructor parameter you have and you don't have to define constructor and default values in your StructureMap configuration method.