0

I'm getting the dreaded "No default Instance is registered and cannot be automatically determined for type" even though I have set a registry for the default conventions.

To debug I am trying the WhatDoIHave and Asset... methods but these no longer exist on ObjectFactory. Am I missing something or have these been removed in the latest version?

4

1 回答 1

1

Jeremy Miller explains new improved error reporting in SM3 3.0 here.

"WhatDoIHave" remains in SM 3: (taken from the above blog entry)

   [Test]
    public void what_do_I_have()
    {
        var container = new Container(x => {
            x.For<IDevice>().AddInstances(o => {
                o.Type<ADevice>().Named("A");
                o.Type<BDevice>().Named("B").LifecycleIs<ThreadLocalStorageLifecycle>();
                o.Type<CDevice>().Named("C").Singleton();
            });

            x.For<IDevice>().UseIfNone<DefaultDevice>();
        });

        Debug.WriteLine(container.WhatDoIHave());

        Debug.WriteLine(container.WhatDoIHave(pluginType:typeof(IDevice)));
    }
于 2014-04-05T07:13:42.590 回答