You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I then inject the named serivces to my controller classes as required:
builder.Register(c => new KeysController(c.ResolveNamed<IService>("ServiceOne")));
builder.Register(c => new ValuesController(c.ResolveNamed<IService>("ServiceTwo")));
Autofac is not able to resolve the IService for both of my controllers by name.
The Exception :
An unhandled exception occurred while processing the request.
InvalidOperationException: Unable to resolve service for type 'AutoFacNaming.IService' while attempting to activate 'AutoFacNaming.Controllers.ValuesController'.
I have attached a sample project which outlines the issue. autofacNaming.zip
The text was updated successfully, but these errors were encountered:
Background :
Issue :
I have two instances of the same service, which I register to the ContainerBuilder with Name:
I then inject the named serivces to my controller classes as required:
Autofac is not able to resolve the IService for both of my controllers by name.
The Exception :
An unhandled exception occurred while processing the request.
InvalidOperationException: Unable to resolve service for type 'AutoFacNaming.IService' while attempting to activate 'AutoFacNaming.Controllers.ValuesController'.
I have attached a sample project which outlines the issue.
autofacNaming.zip
The text was updated successfully, but these errors were encountered: