views:

2334

answers:

1

When I register the following in SM and then attempt to create an instance I get the exception - 'StructureMap Exception Code: 202 No Default Instance defined for PluginFamily...'

Scan(x =>
        {
            x.Assembly("MVCDemo");
            x.Assembly("MVCDemo.Infrastructure");
            x.Assembly("MVCDemo.Services");

            x.AddAllTypesOf(typeof (IRepository<>));
        });

        ForRequestedType<IRepository<Employee>>().TheDefault.Is.ConstructedBy(() => new EmployeeRepository());


 var tmp4 = ObjectFactory.GetInstance<IRepository<Employee>>();

The exception occurs when I try and get an instance of IRepository.

Does anyone know what I'm missing?

Cheers

Ollie

+3  A: 

The answer is I shouldn't use ObjectFactory to create instance, I should use the container:

var container = new Container(new MvcDemoRegistry());
var cultureProvider = container.GetInstance<IProvideCultureInfo>();

Ta

Ollie

AWC