Copied to clipboard

Flag this post as spam?

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


  • Cristhian Amaya 52 posts 423 karma points
    Apr 04, 2014 @ 21:29
    Cristhian Amaya
    0

    Umbraco 7.1.0 upgrade issue with dependency injection

    Hi,

    I'm trying to upgrade Umbraco from 7.0.4 to 7.1.0.

    When Umbraco tries to do the upgrade I get this error:

    <Error>
        <Message>An error has occurred.</Message>
        <ExceptionMessage>
            No constructors on type 'Umbraco.Web.Install.Controllers.InstallApiController' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
        </ExceptionMessage>
        <ExceptionType>Autofac.Core.DependencyResolutionException</ExceptionType>
        <StackTrace>   
            at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)
            at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters)
            at Autofac.Core.Resolving.InstanceLookup.Execute()
            at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters)
            at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters)
            at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable`1 parameters)
            at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.GetInstanceOrActivator(HttpRequestMessage request, Type controllerType, Func`1& activator)
            at System.Web.Http.Dispatcher.DefaultHttpControllerActivator.Create(HttpRequestMessage request, HttpControllerDescriptor controllerDescriptor, Type controllerType)
        </StackTrace>
    </Error>
    

    As you can see I'm using Autofac for DI, this is my configuration:

    var builder = new ContainerBuilder();
    
    builder.Register(c => UmbracoContext.Current).AsSelf();
    
    builder.RegisterControllers(typeof(CommonController).Assembly);
    builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly);
    container = builder.Build();
    
    DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
    
    var resolver = new AutofacWebApiDependencyResolver(container);
    GlobalConfiguration.Configuration.DependencyResolver = resolver;
    

    Is this a bug or I'm doing something wrong?

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 04, 2014 @ 22:57
    Jan Skovgaard
    0

    Hi Christhian and welcome to our :)

    How are you doing the upgrade? Is it manually or using nuget or?

    Make sure you check out the upgrade guide at http://our.umbraco.org/documentation/Installation/

    Hope this helps.

    /Jan

  • Cristhian Amaya 52 posts 423 karma points
    Apr 04, 2014 @ 23:26
    Cristhian Amaya
    0

    Hi Jan,

    I have a project in Visual Studio 2013 where I have installed the UmbracoCms.Core package and a directory where I publish my site. So my upgrading steps were:

    • I Executed Update-Package UmbracoCms.Core in my Vs project
    • I downloaded Umbraco7.1.0.zip
    • I copied Umbraco and Umbraco_Client folders to my published site
    • I merged the web.config file using WinMerge
    • I rebuild my Vs project and published my site
  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 05, 2014 @ 07:41
    Jan Skovgaard
    0

    Hi Christhian

    Ok, try clearing your browser cache - does that help?

    Otherwise try deleting the temporary files in the /config/TEMP/ folder - Don't delete any folders. Just files. So in Examine for instance you need to go down the folder leves and delete only the files. Otherwise it will throw an error.

    When the files are deleted go to /config/ClientDependencyConfig.config and increment the version number.

    Recycle the app pool.

    Does that help?

    /Jan

  • Cristhian Amaya 52 posts 423 karma points
    Apr 05, 2014 @ 11:17
    Cristhian Amaya
    0

    Hi Jan,

    I've tried that but unfortunately it doesn't work yet. It throws the same error.

    Anyway, thanks for your help!

  • Doron 6 posts 28 karma points
    Apr 30, 2014 @ 09:33
    Doron
    0

    Hi Christian,

     

    This is an old post so I'm not sure whether its still relevant,  but as I've just faced this issue, thought I should write this down (Perhaps for future me who will face the same issue and forget he once had it).

    it seems that InstallApiController has a constructor which Autofac cannot resolve.

    You might want to comment out the dependency registration for the upgrad process, or just this line:

      builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly);

    After the installation is completed, uncomment it again.

    Doron

  • Stephan Lonntorp 195 posts 212 karma points
    Dec 11, 2014 @ 19:11
    Stephan Lonntorp
    0

    This is still an issue. Just ran into it when going from 7.1.8 to 7.2.

    Maybe this should be in the installation / upgrade documentation...

  • andrew shearer 510 posts 659 karma points
    Feb 23, 2015 @ 03:08
    andrew shearer
    0

    Was there a fix for this? I got this in 7.2.2

  • Doron Uziel 23 posts 93 karma points
    Feb 23, 2015 @ 05:33
    Doron Uziel
    0

    Have not tried this myself, so am not 100% sure this would work.

    But it seems that the failure is due to the fact that InstallApiController has a dependency on UmbracoContext within its constructor.

    You might want to try to register it with your IOC Container. Assuming its Autofac try something like this:

     builder.Register(c => UmbracoContext.Current).As<UmbracoContext>().SingleInstance();
    

    This might work,

    Doron

  • Murray Roke 503 posts 966 karma points c-trib
    Mar 02, 2015 @ 02:37
    Murray Roke
    0

    looks like it's due to be fixed in 7.2.3 http://issues.umbraco.org/issue/U4-6005

    In the interim, a work-arround is to install a vanilla 7.2.2 upgrade your DB using that install, then go back to your autofac version of the website (update the web.config version to 7.2.2)

    Cheers. Murray.

  • Tommy Enger 72 posts 277 karma points c-trib
    Jun 21, 2016 @ 07:35
    Tommy Enger
    0

    Is this issue fixed by now? In my last project I used SimpleInjector but ended up removing it because of this error. The workflow that Doron describe (comment out -> release -> run upgrade -> remove comment -> release) is not a way I wish to do upgrade in my production environments...

  • Cristhian Amaya 52 posts 423 karma points
    Jun 21, 2016 @ 08:04
    Cristhian Amaya
    0

    I haven't used a setup like this one in some time, but I remember fixing this by registering Umbraco's dlls in the DI container. For example for Autofac would be something like in Doron Uziel's answer.

Please Sign in or register to post replies

Write your reply to:

Draft