Problem with mismatching assemblies for System.Web.Mvc

Vote:
 

In a project where we upgraded to latest version of System.Web.Mvc we get this varing in the Razor views

Assuming assembly reference 'System.Web.Mvc, Version=5.2.3.0 Cultu.... used by Episerver.Cms,AspNet matches identity System.Web.Mvc, Version=5.2.6.0... you may need to supply runtime policy.

We have this in web.config


        
        
      
#193574
May 31, 2018 15:49
Vote:
 

Could it be that you need to update version references in Views/web.config?

#193575
May 31, 2018 15:55
Vote:
 

Having the same issue, did you find a solution?

/Peter

#194103
Jun 13, 2018 16:25
Vote:
 

I get students on the CMS developer courses to fix that error using the following, but if anyone finds a better solution, please let me know!

Suppressing compiler warning CS1702

The EPiServer assemblies are currently compiled for Microsoft.AspNet.Mvc 5.2.3 but you are probably using a later version like 5.2.4. This causes compiler warnings when Razor views are open if they call Episerver extension methods like PropertyFor(). Until Episerver releases new assemblies, you can suppress the CS1702 warning by adding the following to the root Web.config:
<system.codedom>

  <compilers>

    <compiler language="c#;cs;csharp"

              extension=".cshtml"

              compilerOptions="/nowarn:1702"

                   type="Microsoft.CSharp.CSharpCodeProvider, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"

              warningLevel="4">

      <providerOption name="CompilerVersion" value="v4.0" />

      <providerOption name="WarnAsError" value="false" />

    </compiler>

  </compilers>

</system.codedom>
#194109
Jun 13, 2018 17:29
Vote:
 

Thanks Mark, I have no better solution and this works!

#194178
Jun 15, 2018 9:02
Vote:
 
<p>How can I determine which version of&nbsp;<span>Microsoft.AspNet.Mvc a given version of EPiServer is built on? I don't see it listed as a dependency for the EPiServer.CMS Nuget package.</span></p>
#194523
Jun 23, 2018 0:55
Vote:
 

Hi Jesse, you can use .Net framework tool ILDASM.exe to look at any assembly (dll or exe) what are the "exact" references. Open developer command prompt and type: ildasm (hit enter naturally to execute ;P). Then in the app File -> Open (and select you assembly, for example episerver.cms.aspnet.dll) and then double click the "manifest" and from that list you can see the "exact" reference version.

ILDASM

Another option would be to use for example third party application ILSpy to look at the assembly references.

ILSpy

Episerver Microsoft.AspNet.Mvc NuGet dependency is in the EPiServer.Framework.AspNet NuGet package and defined like this (but means I will work with this version range, but not I'm built with these versions):

<dependency id="Microsoft.AspNet.Mvc" version="[5.2.3, 6.0.0)" />
#194573
Edited, Jun 25, 2018 22:11
Vote:
 
<p>Thanks, Antti! I've done this with ILSpy, but didn't know how to do it with IL Disassembler so thanks for the walkthrough. However, I'm wondering how I can determine it without having the assemblies. I want&nbsp;to know when an EPiServer build is available that fixes this error message without having to download each version to inspect it.</p>
#194674
Jun 27, 2018 22:44
Vote:
 

Hi Jesse,

The EPiServer.Framework.AspNet package, which EPiServer.CMS.AspNet depends on, lists Microsoft.AspNet.Mvc as one of its dependencies, so you could just look there.

#199409
Nov 26, 2018 14:56
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.