Why my module has to be installed twice in order to show the menu in the Admin Menu bar?

Topics: Troubleshooting, Writing modules
Jul 1, 2014 at 2:12 PM
Why my module has to be installed twice in order to show the menu in the Admin Menu bar?

The first time install and enable the module, it doesn't show at all;
It only shows when you install it again and enable it again.

Thanks!

AdminMenu.cs
using Orchard.Localization;
using Orchard.Security;
using Orchard.UI.Navigation;

namespace MyModule
{
    public class AdminMenu : INavigationProvider
    {
        public string MenuName
        {
            get { return "admin"; }
        }

        public AdminMenu()
        {
            T = NullLocalizer.Instance;
        }

        private Localizer T { get; set; }

        public void GetNavigation(NavigationBuilder builder)
        {
            builder.Add(item => item.Caption(T("My Module")).Position("3").Action("Index", "Admin", new { area = "MyModule" }).LocalNav().Permission(StandardPermissions.SiteOwner));
        }
    }
}
Developer
Jul 3, 2014 at 6:33 PM
You shouldn't have to do that so this is some bug and it seems that for some reason the new shell state (where the module is enabled) is not applied correct. What happens if you restart the site after enabling the module the first time? Does the menu appear?
Jul 4, 2014 at 8:16 PM
Thanks Piedone,

You are absolutely right - restart the server (IIS) fix would show the menu!!!
So what is the problem, how to fix that?

Thanks!
Developer
Jul 4, 2014 at 9:37 PM
It seems that the shell cache is somehow getting stale for you. Do you see any entries in the logs? What happens if you disable ShellDescriptorCache from HostComponents.config?