Copied to clipboard

Flag this post as spam?

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


  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Mar 01, 2016 @ 11:50
    Bo Damgaard Mortensen
    0

    Tree is not rendering

    Hi all,

    First off: thanks for a great package! :-)

    I've installed Newsletter Studio on an Umbraco 7.4.1 site and I'm getting an error when accessing the Newsletter Studio section and the tree is not rendering.

    The error I'm getting is as follows:

    enter image description here

    I've checked trees.config and everything seems just fine there.

    Does anyone know of a fix for this? Every other section are rendering just fine :-)

    Thanks in advance.

  • Markus Johansson 1675 posts 4757 karma points c-trib
    Mar 01, 2016 @ 11:53
    Markus Johansson
    0

    Hi Bo!

    Thanks for using the package! =D

    What version of the package are you running?

    Are you sure that there is no duplicates in the tree/application.config-files? I've seen some installs where this happens.

    Cheers!

    / m

  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Mar 01, 2016 @ 12:06
    Bo Damgaard Mortensen
    0

    Hiya Markus,

    Thanks a lot for the fast response :-)

    Yes, I'm 100% sure the config files are as they should be. I'm using the very latest version of Newsletter Studio.

    Meanwhile, I've made a finding: in separate project, I'm hooking into the OnApplicationStarted event of Umbraco to register some custom controllers (my solution is all strongly typed) Now, if I remove that code, it works just fine, so it seems that AutoFac is disturbing the tree from rendering, somehow.

    My OnApplicationStarted event looks like this:

    public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            // Using AutoFac nuget package for dependency injection
            // Create a new containter builder
            var builder = new ContainerBuilder();
    
            // Register umbraco context, mvc controllers and api controllers
            builder.Register(c => UmbracoContext.Current).AsSelf();
            builder.RegisterControllers(Assembly.GetExecutingAssembly());
            builder.RegisterApiControllers(typeof(UmbracoApplication).Assembly);
    
            // Register MVC conrollers            
            builder.RegisterControllers(typeof(PortalController).Assembly);
                                       builder.RegisterType(typeof(CycloneEntities)).InstancePerLifetimeScope(); // inject one Cyclone domain context per http request
    
            // Build container
            var container = builder.Build();
    
            // Set resolver
            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
    
            // Custom MVC model binders
            ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder());
    
            // Frontend bundling
            #if !DEBUG
            RegisterJavaScript(BundleTable.Bundles);
            #endif
        }
    

    Are you using AutoFac aswell in your Newsletter Studio solution? :-) Seems like there's some kind of mismatch going on along the lines..

    Thanks again!

  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Mar 01, 2016 @ 12:29
    Bo Damgaard Mortensen
    0

    .. and diggin' in further, this is the line that makes it not render the tree:

    DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
    

    However, removing the line breaks all of my controllers since they're taking the CycloneEntities object as parameter in the constructor.

  • Bo Damgaard Mortensen 712 posts 1189 karma points
    Mar 01, 2016 @ 12:59
    Bo Damgaard Mortensen
    100

    Alright, found a solution!

    I simply added this to the OnApplicationStarted event of Umbraco:

    builder.RegisterApiControllers(Assembly.Load("NewsletterStudio"));
    

    Made it work right away :-)

  • Markus Johansson 1675 posts 4757 karma points c-trib
    Mar 01, 2016 @ 13:16
    Markus Johansson
    0

    Thanks for sharing! I also had some issues with DI after upgrading to 7.4.1 on a site without the newsletter-package.

    // m

Please Sign in or register to post replies

Write your reply to:

Draft