0

I have one service with two different components

<component type="ConcreteA, ConcreteA" service="Interface, Interface" />
<component type="ConcreteB, ConcreteB" service="Interface, Interface" />

I want to resolve both. I am trying in this way

var builder = new ContainerBuilder();
builder.RegisterModule(new ConfigurationSettingsReader());
builder.RegisterControllers(typeof(MvcApplication).Assembly);

this._container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(this._container));

Now in my controller I want to resolve my dependency

public Interface _myInterface { get; set; }

And I use it in this way:

_myInterface.DoWork();

If I declare in the config just one component everything works perfectly. But If I add more component of the same Interface type, something goes wrong. I have tried to replace the declaration of the property with

public List<Interface> _myInterfaces { get; set; }

But the property remain always null... How can I do?

Thank you

Simone
  • 2,304
  • 6
  • 30
  • 79

1 Answers1

0

Resolved with

public Interface[] _myInterfaces { get; set; }

instead of

public List<Interface> _myInterfaces { get; set; }
Simone
  • 2,304
  • 6
  • 30
  • 79