Search code examples
asp.net-mvc-4sitecoresitecore7glass-mapper

Error: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies


I want my fields to be editable in sitecore (supports page editors). I am using MVC 4.0 and Glass Mapper to map the fields. After reading article Page Editing in MVC , I used

 @inherits Glass.Mapper.Sc.Web.Mvc.GlassView<My Model Class>

to get the >@Editable in my Partial view but when I use inherits keyword, my page gets below error message

Error: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference

Could someone please suggest how to @Editable keyword to edit my fields in Sitecore with MVC 4.0 and Glass Mapper version - 3.0.10.23. Other version are

Glass.Mapper.Sc version - 3.2.0.39

Glass.Mapper.Sc.Mvc version - 3.2.0.34

My View looks like below

@using Sitecore.Mvc
@using Test.Libraries.Sitecore.Glass.Mapper.Common;
@inherits Glass.Mapper.Sc.Web.Mvc.GlassView<Test.Libraries.Sitecore.Glass.Mapper.Common.Footer>

   <h2>@Editable(x=>x.Title)</h2>

 View which works is

@using Sitecore.Mvc
@using Test.Libraries.Sitecore.Glass.Mapper.Common;
@model Footer

   @Model.PageTitle

Please suggest. Thanks


Solution

  • Try adding a binding redirect from MVC 3 -> MVC 4...

    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Helpers"
                 publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.Mvc"
                 publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.0"/>
          </dependentAssembly>
          <dependentAssembly>
            <assemblyIdentity name="System.Web.WebPages"
                 publicKeyToken="31bf3856ad364e35" />
            <bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0"/>
          </dependentAssembly>
        </assemblyBinding>
      </runtime>
    </configuration>
    

    Add to the web.config of your web project (assuming that's possible with sitecore?).