Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Ismail Mayat 4267 posts 9146 karma points MVP 2x admin c-trib
    1 week ago
    Ismail Mayat
    0

    Make sure that the controller has a parameterless public constructor

    I am in the process of upgrading the package https://our.umbraco.com/packages/backoffice-extensions/redirects-viewer/ to v8.

    When creating a property editor I am getting an error with one of the controllers the error is:

    An error occurred when trying to create a controller of type 'UserGroupsApiController'. Make sure that the controller has a parameterless public constructor

    The controller inherits from BackOfficeNotificationsController this does not have parameterless constructor only inherited one that must have dependencies injected into it.

    The inner states:

    System.InvalidOperationException: Unresolved dependency [Target Type: Our.Umbraco.RedirectsViewer.Controllers.UserGroupsApiController], [Parameter: mapper(AutoMapper.IMappingEngine)], [Requested dependency: ServiceType:AutoMapper.IMappingEngine, ServiceName:]

    In my composer I have:

            composition.Register<IMappingEngine,MappingEngine>(Lifetime.Singleton);
    

    So I am setting it up, am I missing something?

    Regards

    Ismail

  • Ismail Mayat 4267 posts 9146 karma points MVP 2x admin c-trib
    1 week ago
    Ismail Mayat
    100

    So got a bit further with this, I updated automapper to latest version then in my composition I now have:

    var config = new MapperConfiguration(cfg => {
                cfg.AddProfile<UserGroupProfile>();
            });
    
            IMapper mapper = new Mapper(config);
    
            composition.Register(mapper);
    

    Is there better way to register this? Also I want to register as singleton lifetime how would i do this?

    Regards

    Ismail

Please Sign in or register to post replies

Write your reply to:

Draft