Copied to clipboard

Flag this post as spam?

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


  • Sebastian Budka 12 posts 93 karma points
    Jul 06, 2020 @ 09:42
    Sebastian Budka
    0

    Composing application can't inject Umbraco dependencies

    We are using Windsor for DI in our project. While in v7 it was working properly, now cannot inject Umbraco dependencies when appliaction starts. Here are sample codes:

    [RuntimeLevel(MinLevel = RuntimeLevel.Run)]
    public class ApplicationComposer : IUserComposer
    {
        public void Compose(Composition composition)
        {
            using (Container.Current.BeginScope())
            {
                try
                {
                    Container.Current.CastleContainer.Install(new WebClientInstaller()
                }
                finally
                {
                    Container.Current.Release(log);
                }
            }
        }
    }
    

    We want to be able to inject some of umbraco dependencies, but Current.Services (along with many others) seems to be unavailable during composition

    container.Register(
        Component.For<IContentService>()
            .Instance(Current.Services.ContentService)
            .LifeStyle.Scoped<HybridCustomScopeAccessor>());
    

    How can we overcome this?

Please Sign in or register to post replies

Write your reply to:

Draft