Question

I am a little lost as to where I need to look to resolve the error message below.

The history is that I added a new service object to the project and instantiate / inject it when a new section of the site is accessed. (MVC 3 site repository/service architecture).

The error is:

Cannot resolve parameter 'XService pl_xService' of constructor 'Void .ctor(.....

Now this is straight forward enough to understand. The newly added parameter XService can't be resolved...

The error is thrown by Autofac.core.dependency but I am not sure where / how I would register my new object for Autofac.

I understand you have no clue how my project is setup so I'm just looking for greater understanding of what is going on thus enabling me to track down where I need to register my new service object with Autofac etc.

FWIW:

Controller for new section of the site:

public partial class NewSectionController : BaseController
{
    private readonly IPL_XService _pl_xService;

    #region Constructors

    public NewSectionController(IPL_XService pl_xService,....)
    {
        this._pl_forumService = pl_forumService;
    }

    .....controller actions, helpers, utilities etc.........
 }

Since I am in waters I have not spent much time (if any really) in please let me know of any other code, style, architecture etc. that I can post to help make the question better.

Thank You

Was it helpful?

Solution

Just search for ContainerBuilder class, and then add this code:

var builder = new ContainerBuilder();
builder.RegisterType<PL_XService>().As<IXService>().InstancePerHttpReques‌​t();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top