Unity and the Factory Pattern

Jan 15, 2009 at 12:57 PM
Very simple question - 'must the classes I am instantiating using DI have to have  (or be capable of having, i.e. there is no constructor so a default constructor is assumed) a PUBLIC constructor?'

My codebase currently uses a variation of Factory Pattern (specific containers have been used to instantiate the concrete type) and the class that they instantiate have 'internal protected' constructors, i.e. they have no public constructor. 
I haven't looked at Unity 1.2 so I apologise if this is already achievable.

Jan 15, 2009 at 1:40 PM
Edited Jan 15, 2009 at 1:51 PM
Yes,  they should have public constructors.  Resolving classes with no public constructors is not supported in Unity.  See this post...

Sarah Urmeneta
Global Technology & Solutions
Avanade, Inc.