Resolving an unregistred type by name

Sep 9, 2008 at 10:39 AM
Edited Sep 9, 2008 at 10:44 AM


According to this note at:

If the container does not contain a mapping for the specified combination of type and name, it will raise an exception. Also remember that names are case-sensitive.

This test should throw an exception:


public class AppleTests



    public void CanCreateNonexistingNamedEntry()


        IUnityContainer container = new UnityContainer();


        var apple = container.Resolve<Apple>("someRandomString");





    public class Apple { }


but it doesn't - it actaully returns an instance ... anyone knows more about this?

Sep 9, 2008 at 7:54 PM
The docs are wrong. In that case, Unity will treat it just like any other unregistered type, and create a new transient instance.