Module Development - Some features need to be upgraded:

Topics: Administration, Core, Customizing Orchard, Writing modules
Jan 7, 2014 at 8:00 PM
I am following the series on module development:
http://skywalkersoftwaredevelopment.net/blog/writing-an-orchard-webshop-module-from-scratch-part-1

I reached Part 10 and added the AdminMenu.cs class to the root of the module. I get the following message in the Dashboard:
Some features need to be upgraded: Orchard.Webshop
Also, the menu only shows:
Webshop
  • Orders
Customers not showing although using this class:
using Orchard.Localization;
using Orchard.UI.Navigation;

namespace Orchard.Webshop
{
    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

                // Image set
                // An image set is actually nothing more than a name that you specify. 
                // Orhard uses it to automatically include a stylesheet named 
                // "menu.webshop-admin.css" which you'll have to create yourself.
                // The stylesheet should contain css rules that apply to the individual menu items
                .AddImageSet("webshop")

                // "Webshop"
                .Add(item => item

                    // The css class will be "navicon-webshop"
                    .Caption(T("Webshop"))
                    .Position("2")
                    .LinkToFirstChild(true)

                    // "Customers"
                    // css class "subnavicon-customers"
                    .Add(subItem => subItem
                        .Caption(T("Customers"))
                        .Position("2.1")
                        .Action("Index", "CustomerAdmin", new { area = "Orchard.Webshop" })
                    )

                    // "Orders"
                    // css class "subnavicon-orders"
                    .Add(subItem => subItem
                        .Caption(T("Orders"))
                        .Position("2.2")
                        .Action("Index", "OrderAdmin", new { area = "Orchard.Webshop" })
                    )
                );
        }
    }
}
Thanks
Developer
Jan 7, 2014 at 9:41 PM
That's probably because an error is occurring. Please check the log files and/or attach the debugger (make sure to have it break when .NET exceptions are Thrown, because there's almost everywhere a try/catch block up the stack) to see the exception occurring (if any) so you can investigate what it is and why it's happening.
Jan 8, 2014 at 9:20 AM
In the migration.cs file, some table names were copied directly from your article, and I had a different naming, I fixed that and it runs without that message to upgrade. However, still the menu is not showing the "Customers" link.

I am running the solution with Ctrl+F5.

Thanks
Jan 8, 2014 at 9:50 AM
I noticed this also. I already have a reference to the MVC DLL 4.0.
2014-01-08 11:44:22,822 [9] Orchard.Environment.DefaultBuildManager - Error when compiling assembly under ~/Modules/Orchard.Webshop/Orchard.Webshop.csproj.
System.Web.HttpCompileException (0x80004005): d:\Dev\Repos\Orchard\src\Orchard.Web\Modules\Orchard.Webshop\ViewModels\SignupViewModel.cs(27): 
error CS0246: The type or namespace name 'Compare' could not be found (are you missing a using directive or an assembly reference?)
   at System.Web.Compilation.BuildManager.PostProcessFoundBuildResult(BuildResult result, Boolean keyFromVPP, VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetBuildResultFromCacheInternal(String cacheKey, Boolean keyFromVPP, VirtualPath virtualPath, Int64 hashCode, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultFromCacheInternal(VirtualPath virtualPath, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean throwIfNotFound, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetVPathBuildResult(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile, Boolean ensureIsUpToDate)
   at System.Web.Compilation.BuildManager.GetCompiledAssembly(String virtualPath)
   at Orchard.Environment.DefaultBuildManager.GetCompiledAssembly(String virtualPath) in d:\Dev\Repos\Orchard\src\Orchard\Environment\IBuildManager.cs:line 53
Jan 8, 2014 at 9:49 PM
Any idea?
Developer
Jan 8, 2014 at 10:02 PM
bhaidar wrote:
In the migration.cs file, some table names were copied directly from your article, and I had a different naming, I fixed that and it runs without that message to upgrade. However, still the menu is not showing the "Customers" link.
Did you try and set a breakpoint in the AdminMenu class to see if it gets hit at all?
Developer
Jan 8, 2014 at 10:04 PM
Regarding the compilation error, do all projects reference the correct MVC DLL version, and is the correct version included in the web.config files (check the root and the web.config files in Views folders). Also check for binding redirects, perhaps something's not right there.
Jan 8, 2014 at 10:25 PM
The root Web.config file contains the following:
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

The Views folder web.config contains the following:
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="2.0.0.0" newVersion="3.0.0.0" />
the 4.0 version is being referenced under "References"
Developer
Jan 8, 2014 at 10:31 PM
Did you try changing 3.0.0.0 to 4.0.0.0? Are all projects referencing 4.0? Including Orchard.Web, Orchard.Core and Orchard.Framework? Or are they referencing 3.0? Make sure that your module references the same version as what's used by Orchard.
Jan 9, 2014 at 2:23 PM
Hi Sipke,

I made sure all are using 4.0. I will see if the problem appears again.

Regarding the menu, I used F12 inside Firefox and noticed the following:
            <h3><span class="expando-glyph-container open"><span class="expando-glyph"></span>​</span><a class="navicon-webshop" href="/OrchardLocal/Orchard.WebShop/CustomerAdmin">Webshop</a></h3>
                <ul style="display: block;" class="menuItems">
    
<li>                            <a href="/OrchardLocal/Orchard.WebShop/OrderAdmin" class="subnavicon-orders">Orders</a>
</li>                </ul>
Customers menuitem is not shown, however, the Parent Webshop is taking its place, you can notice this from the "href".

any idea why?

Thanks
Jan 9, 2014 at 11:05 PM
I had to add the following to show both "Customers" and "Orders"
.Add(subitem => subitem
                    .Caption(T("Webshop"))
                    .Action("", "", new { area = "Orchard.Webshop" })
                )

                .Add(subitem => subitem
                    .Caption(T("Cusotmers"))
                    .Action("Index", "CustomerAdmin", new { area = "Orchard.Webshop" })
                )


                .Add(subitem => subitem
                    .Caption(T("Orders"))
                    .Action("Index", "OrderAdmin", new { area = "Orchard.Webshop" })
                );
Regards