Copied to clipboard

Flag this post as spam?

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


  • Andrew Munro 78 posts 161 karma points
    Oct 30, 2012 @ 02:12
    Andrew Munro
    0

    Custom tree and application not registering in 4.9

    Hi Guys. I am attempting to create a custom application and tree in my site. I've implemented the tree and application.For my tree I've implemented BaseTree and used the Tree attribute on the class to mark it as a tree. For my application I've done the same with IApplication and the application attribute.

    When I start my application, everything gets added correctly into the trees.config and applications.config but nothing gets added to the database. Am I correct in assuming that the two config files should also sync to the database?

    Any help would be appreciated. Thank you.

  • Pasang Tamang 258 posts 458 karma points
    Oct 30, 2012 @ 02:40
    Pasang Tamang
    0

    Hi Andrew,

    From the U4.9 the custom tree settings has been moved to config. Database tables are still there but no need to sync. 

    Thanks
    PTamang

  • Andrew Munro 78 posts 161 karma points
    Oct 30, 2012 @ 19:34
    Andrew Munro
    0

    Hey. Thank you for the reply.  Now that I am at my workstation i can provide a bit more information. I have tried restarting the app pool (restarting IIS, restarting the pool, restarting the machine)  but none of these options worked. I thew in some test email code just to see if the class ever gets loaded but this also didn't work.

    Here is my Tree definition

     [Tree("humanresources", "resumes", "Resumes")]
        public class loadResumes : BaseTree
        {
            public loadResumes(string application)
                : base(application)
            { }
    
            protected override void CreateRootNode(ref XmlTreeNode rootNode)
            {
                ErrorHandler.New().SetException(new Exception("in CreateRootNode")).Email().Handle();
                rootNode.Icon = FolderIcon;
                rootNode.OpenIcon = FolderIconOpen;
                rootNode.NodeType = TreeAlias;
                rootNode.NodeID = "init";
                ErrorHandler.New().SetException(new Exception("finished CreateRootNode")).Email().Handle();
    
            }
            public override void RenderJS(ref StringBuilder Javascript)
            {
                ErrorHandler.New().SetException(new Exception("in RenderJS")).Email().Handle();
                Javascript.Append(@"
                    function openResume(id)
                    {
                        parent.right.document.location.href = 'http://www.google.ca';
                    }
                ");
            }
    
            public override void Render(ref XmlTree tree)
            {
                ErrorHandler.New().SetException(new Exception("in RenderJS")).Email().Handle();
                List<string> ls = new List<string>();
                ls.Add("hi");
                ls.Add("hello");
                int iCount = 0;
                foreach (string s in ls)
                {
                    XmlTreeNode xNode = XmlTreeNode.Create(this);
                    xNode.NodeID = iCount.ToString() ;
                    xNode.Text = s;
                    xNode.Icon = "hr.gif";
                    xNode.Action = "javascript:openResume('1')";
                    tree.Add(xNode);
                    iCount++;
                }
            }
        }

    Here is my Application definition

        [Application("humanresources","Human Resources", "myapp.gif")]
        public class HumanResourcesApplicationDefinition : IApplication
        {
        }

    Here is the relevant line automatically added to my trees.config

     <add silent="false" initialize="true" sortOrder="0" alias="resumes" application="humanresources" title="Resumes" iconClosed=".sprTreeFolder" iconOpen=".sprTreeFolder_o" assembly="MyOrg.Umbraco.HumanResources" type="loadResumes" action="" />

    Here is the relavant line automaticaly added to my applications.config

     <add alias="humanresources" name="Human Resources" icon="myapp.gif" sortOrder="7" />

    I've enabled debug mode so that I can see if anything is getting logged to the umbracoLog table but nothing shows up. I can pretty much say that my tree classes are being ignored while loading but I'm quite unsure as to why. Thank you!

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Oct 30, 2012 @ 22:21
    Matt Brailsford
    1

    Hey Andrew,

    Looking at the above, I can't see anything specific that would cause your tree not to load. I'd say double check you've recycled your app pool, but I would imaging this should have happened when you dropped the dll in the bin folder.

    Have you tried debugging? Do any of the methods on your tree ever get called? Using BaseTree shouldn't be a problem, as that is what all the internal trees are doing, but have you tried just implementing ITree? Could be worth a try to see if anything funky is going on.

    Matt

  • Andrew Munro 78 posts 161 karma points
    Oct 30, 2012 @ 22:51
    Andrew Munro
    0

    Hey Matt. I've tried all sorts of recycling methods and none of them seem to work.

    I've tried debugging too but it never makes it into my tree class. Also, I have tried implmenting ITree but I run into the same issue. 

    Quick question, should I need to specify a namespace or will the TypeFinder find it automatically. If i did have to, would that I specify that in the assembly or the type attribute?

    Thanks again for all the help/

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Oct 30, 2012 @ 23:00
    Matt Brailsford
    1

    Hi Andrew,

    The type is already defined in the XML config, namely the assembly attribute and type attribute, which get combined to represent the namespace of the trees type. I would imagine though, if Umbraco created the config entries, they should be right.

    I think it might require some debugging into the Umbraco source to see what is going on and why it's not getting picked up. It's getting late here in the UK, but I'll try creating a similar tree in the morning and see if I can replicate your problem.

    Cheers

    Matt

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Oct 30, 2012 @ 23:04
    Matt Brailsford
    1

    Oh wait, have you given the current user access to your application? In the edit user dialog, be sure to give your user permission to your new application.

    Matt

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Oct 30, 2012 @ 23:07
    Matt Brailsford
    1

    Ok, I've actually just tested it, and I'm pretty sure it's what I mentioned above. By default, your user won't have access to your application. You have to enable it in the edit user screen for your current user. I just recreated your classes, and enabling this got them both to display.

    Hope that helps

    Matt

  • Andrew Munro 78 posts 161 karma points
    Oct 30, 2012 @ 23:10
    Andrew Munro
    0

    Thanks Matt. That was my first thought but when I go into the users section, the application doesn't even appear in the sections list. I wonder if the sections list is being cached somehwere. 

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Oct 30, 2012 @ 23:16
    Matt Brailsford
    1

    Dang! that is weird. I just copied exactly what you had and compiled it. Dropped the DLL in the bin folder, restarted the app pool which added the entries to the application / tree configs. Went to user editor and I am able to enable the application for the user and everything just worked. A new app was added to the tray and going to that section loads the tree.

    What happens if you just add a entry to your applications.config by hand and restart the app pool? it should get listed in the user editor as a section to enable. If not, then yea, it sounds like you've got something funky going on.

    Matt

  • Andrew Munro 78 posts 161 karma points
    Oct 30, 2012 @ 23:27
    Andrew Munro
    0

    This is very strange. Adding an entry to applications.config does nothing. Even after an IIS reset.

  • Andrew Munro 78 posts 161 karma points
    Oct 31, 2012 @ 19:27
    Andrew Munro
    0

    One other condiseration. Should I have to add anything to the lang files. I know this was previosly a step. I'm just trying to figure out if I missed something simple.

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Oct 31, 2012 @ 19:38
    Matt Brailsford
    1

    Hey Andrew,

    You shouldn't do. It should be as simple as defining it in the config file and it should get picked up. Is this a fresh install? or an upgrade?

    Matt

  • Andrew Munro 78 posts 161 karma points
    Oct 31, 2012 @ 20:03
    Andrew Munro
    0

    This is an upgrade. My fresh install was back at 4.7 so I naturally thought that It was an old library reading the configuration. I've tried replacing the bins with the 4.9.1 but that didn't show any improvement. 

    I'm completley stumped. It doesn't appear that changing my application.config does anything.

    Under normal circumstances, should adding an entry to my applications.config actually show that application right after app pool restart?

     

     

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Oct 31, 2012 @ 20:08
    Matt Brailsford
    1

    Hi Andrew,

    After adding to app.config, it should make it available in the user editor to enable straight after an app pool restart.

    Out of curiocity, can you try adding an application via the database? rather than the config. Table umbracoApp. It should be the exact same format. If that shows up, then it sounds like you do have a cached assembly. Have you cleared out your temp asp.net files?

    Matt

  • Andrew Munro 78 posts 161 karma points
    Oct 31, 2012 @ 21:34
    Andrew Munro
    0

    Ohh man... I don't belive it myself but it works. Here was the struggle:

    Out of curiosity I tried removing section permissions for things like the members section to see if it would refresh the sections list. Oddly enough, rather than unassigning the permission, it removed them from the sections option comtpletley! Despite the fact that my account was an administrator, once I removed the permissions, I could not get them back. My theory at this point was that if unassigned section permissions were invisible, perhaps my application and trees were in the list of invisible sections.

    My next step was to log in using the main admin account  and see what permissoins we available. Much to my surprise, all of the lost sections were there, including my own custom one.

    My final question, as an administrator, should these sections be dissapearing once I remove permissions or should I see them regardless? If they should still be visible then I should probably create a bug ticket for this. As it stands right now, only my main admin account can see sections that have not been assigned to a users.

     

    Thanks again for all of your help. Your help has been invaluable.

     

     

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Oct 31, 2012 @ 21:37
    Matt Brailsford
    1

    Hey Andrew,

    Aaaaaaaah! That'll be why it worked ok for me then, as I always log in as Admin. I would imagine that if you are assigned admin role, that those should be available to enable / disable, so I would say to go report it as a bug.

    Glad you managed to get it working though.

    Matt

  • John 10 posts 161 karma points
    Mar 08, 2013 @ 13:30
    John
    0

    I've encountered this issue too, after having upgraded from 4.7.0 to 6.0.2. I've added a comment to the issue with a screencast reproducing the steps.

  • Zac 223 posts 575 karma points
    Aug 29, 2013 @ 16:15
    Zac
    0

    I've also encountered this bug. The application won't register

  • Tom W 39 posts 96 karma points
    Feb 11, 2014 @ 17:21
Please Sign in or register to post replies

Write your reply to:

Draft