Tuesday, March 18, 2014

Deploying a site that has been upgraded to EPiServer 7.6

When you upgrade a site to EPiServer 7.6 it might be a good idea to keep a close eye on what is happening during the upgrade.

Well, the upgrade makes some changes to your AppData folder, so your next one-click deployment will not work as expected (unless you've included the AppData folder in your deployment process, in which case: shame on you). EPiServer has described the "Changes to location of package contents when upgrading" and blogged about the new add-ons location, and it's a good idea to read these if you run into trouble.

I experienced this yesterday, I deployed a new version of the site I'm working on to test and the website crashed.

The errors I received were along the lines of:

System.ArgumentException: An item with the same key has already been added.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Collections.Generic.Dictionary`2.System.Collections.Generic.ICollection>.Add(KeyValuePair`2 keyValuePair)
   at EPiServer.Web.Mvc.Html.QuickNavigatorHtmlHelperExtensions.RenderEPiServerQuickNavigator(HtmlHelper htmlHelper, String partialViewName)

This is another error I received:

System.Web.HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerWrapper'. ---> System.Web.HttpUnhandledException (0x80004005): Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ArgumentException: An item with the same key has already been added.
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
   at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement](IEnumerable`1 source, Func`2 keySelector, Func`2 elementSelector, IEqualityComparer`1 comparer)
   at EPiServer.Cms.Shell.CmsModuleViewModel..ctor(ShellModule module, IClientResourceService clientResourceService, IEnumerable`1 contentRepositoryDescriptors)
   at EPiServer.Cms.Shell.CmsModule.CreateViewModel(ModuleTable moduleTable, IClientResourceService clientResourceService)

So what was the problem? Well, the problem was that the code that was deployed had been upgraded to 7.6, but the neccessary changes needed to make 7.6 work had not been done on the test server.

What I did to fix this was:
  1. Delete the Modules and ModulesRepository folders in AppData on the test server
  2. Copy the Modules and ModulesRepository folders from the dev environment to the test server (the upgrade had been done on the dev environment, so we knew these folders were correct)
  3. Delete the following assemblies from the modulesbin folder on your site root: 
    • EPiServer.Shell.UI.dll
    • EPiServer.Cms.Shell.UI.dll
    • EPiServer.Cms.Shell.UI.Sources.dll.  If your site uses Commerce, you'll also have to delete these: EPiServer.Commerce.AddOns.UI.dll and EPiServer.Commerce.AddOns.Manager.dll
  4. Make sure the modules/_protected folder exists on your site root.
For more details, I recommend reading the readme.txt files for the upgrade:
EPiServer.Commerce.UI (for commerce sites)

1 comment:

  1. Hi Karoline,
    Despite having a working site I'm still confused about the AppData folder after upgrading, I wonder if you can clarify some things for me? We have our site load balanced across 2 servers, and the blob and search index folders on a separate server. My questions are:

    1. Where should the AppData folder be? Do we put this in a shared location too? Or should it be in the root of the site? Or should it be at the same level as the site root?

    2. Should we put it under source control? (see http://world.episerver.com/Forum/Developer-forum/EPiServer-7-CMS/Thread-Container/2013/5/Putting-the-AppDataModules-and-AppDataModulesRepository-in-source-control/)

    3. What should be in it now? Just Geolocation, Modules, ModulesRepository, TemporaryRepository? blobs and Index are shared, as mentioned.

    4. Lastly, should it be called AppData or App_Data (i'm assuming it doesn't matter, but just for consistency sake). This says App_Data: http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-CMS/75/Deployment/Deployment-scenarios/Deploying-to-Windows-Servers/

    Thanks very much,