We have updated our base solution which just contains a few example renderings from Sitecore 8.1 to 8.2. Note: we are still using VS 2013, but I don't think this should be any problem?

I have updated the references and I think I've tried just about everything in terms of removing and re-adding references, deleting readding and updating Nuget packages.

In my Views whenever I use Glass Mapper editable e.g.

@Editable(Model.DataItemModel, x=>x.HeaderText)

I'm getting x=>x.HeaderText underlined with this error:

Error   4   Cannot convert lambda expression to type
because it is not a delegate
type    c:\Projects\SitecoreMVC\Code\SitecoreMVC\Project.Web\Views\Shared\_Header.cshtml

I can't figure out what has changed. Can anyone help?

  • Did you also upgrade Glass.Mapper to the newest version? Dec 15, 2016 at 13:14
  • Yep version
    – DaveBeta
    Dec 15, 2016 at 13:16
  • Could you compare the contents of your /Views/Web.config and /Areas/*/Views/Web.config to the default /Views/Web.config that comes with Sitecore 8.2? They should be (in most cases) identical. Dec 15, 2016 at 15:17
  • Yeah it is identical because I used the one that comes with 8.2 This is still driving me bonkers
    – DaveBeta
    Dec 15, 2016 at 18:15
  • @DaveBeta Is this a problem only in Visual Studio? Do the pages actually work correctly? Have you tried restarting Visual Studio? ;-) Dec 15, 2016 at 19:27

1 Answer 1


This error (as well as many other errors) happens because of a mismatch between the used and the targeted versions of ASP.NET MVC binaries.

Sitecore 8.2 uses version of the following assemblies:

  • System.Web.Mvc
  • System.Web.Http
  • System.Web.Http.WebHost
  • System.Net.Http.Formatting
  • System.Web.Http.Cors

You need to make sure that you have the version of these assemblies:

  • for corresponding DLLs residing in your bin folder
  • in Web.config under configuration > system.web > compilation > assemblies
  • in the redirects in Web.config under configuration > runtime > assemblyBinding, for example:

        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" xmlns="urn:schemas-microsoft-com:asm.v1" />
        <bindingRedirect oldVersion="" newVersion="" xmlns="urn:schemas-microsoft-com:asm.v1" />
  • in installed NuGet packages

  • in references of all of your Sitecore projects
  • in Web.config files (if you have any) under /Views and /Areas/*/Views, for example:

    <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
        userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
        <add assembly="System.Web.Mvc, Version=, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />

You also need to ensure that the target framework in all of your projects, as well as in Web.config, is set to 4.5.2.

The error should be fixed after you perform the steps above.

  • I'm still double checking, but I don't think this is the problem. The issue appears to be related to Linq. I noticed Linq expressions such as Any aren't working in Views! @if (Model.DataItemModel.CommentFolder.Comments.Any()) Error 6 'System.Collections.Generic.IEnumerable<Project.Entities.Comment>' does not contain a definition for 'Any' and no extension method 'Any' accepting a first argument of type 'System.Collections.Generic.IEnumerable<Project.Entities.Comment>' could be found (are you missing a using directive or an assembly reference?)
    – DaveBeta
    Dec 15, 2016 at 15:08
  • @DaveBeta OK, that sounds like a completely separate problem. Make sure that you either have @using System.Linq in your view, of <add namespace="System.Linq" /> in your /Views/Web.config under system.web.webPages.razor > pages > namespace. Dec 15, 2016 at 15:13
  • If I add @using System.Linq it underlines Linq does not exist
    – DaveBeta
    Dec 15, 2016 at 15:32
  • Linq works fine in a controller though
    – DaveBeta
    Dec 15, 2016 at 15:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.