We have moved!

You are currently looking at documentation for Umbraco 8 and older versions.
An automated guess is that docs.umbraco.com/umbraco-cms/implementation/services/circular-dependencies/ could be the link to the new documentation for Umbraco 9 and newer versions.

    Circular Dependencies

    In some cases you might experience that a circular dependency is preventing your Umbraco installing from starting up.

    An example of this, could be a circular dependency on IUmbracoContextFactory, which would happen if your service interacts with third party code that also depends on an IUmbracoContextFactory instance.

    In this situation, you can request a lazy version of the dependency so it won't evaluate during boot, and would only be evaluated when accessed:

    public class SiteService : ISiteService
    {
        private readonly Lazy<IUmbracoContextFactory> _umbracoContextFactory;
        public SiteService(Lazy<IUmbracoContextFactory> umbracoContextFactory)
        {
            _umbracoContextFactory = umbracoContextFactory;
        }
         public IPublishedContent GetNewsSection()
        {
             using (UmbracoContextReference umbracoContextReference = _umbracoContextFactory.Value.EnsureUmbracoContext())
             {
                 // Do your thing
             }
        }
    }