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;
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
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.
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:
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)
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...
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.
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:
As you can see I'm using Autofac for DI, this is my configuration:
Is this a bug or I'm doing something wrong?
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
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:
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
Hi Jan,
I've tried that but unfortunately it doesn't work yet. It throws the same error.
Anyway, thanks for your help!
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
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...
Was there a fix for this? I got this in 7.2.2
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:
This might work,
Doron
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.
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...
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.
is working on a reply...