1

Complete error: Inheritance security rules violated by type: 'System.Web.WebPages.Razor.WebPageRazorHost'. Derived types must either match the security accessibility of the base type or be less accessible.

Please note: according to some commenting out this would help, but it doesn't work

<dependentAssembly>
        <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>

If, I comment it, it shows another error here:

Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

halfer
  • 19,824
  • 17
  • 99
  • 186
  • [This might](https://stackoverflow.com/questions/15874366/could-not-load-file-or-assembly-system-web-razor-or-one-of-its-dependencies) help. I've encountered issues similar to this when migrating MVC 4 projects to MVC 5. Try creating a new MVC project with whatever desired version you want to use, update the NuGet packages, and see what the web.config looks like. – alex Oct 12 '17 at 13:39
  • [Possibly related](https://stackoverflow.com/questions/27576750/error-inheritance-security-rules-violated-by-type-system-web-webpages-razor-w). – halfer May 19 '18 at 09:36
  • 1
    Possible duplicate of [Error: Inheritance security rules violated by type: 'System.Web.WebPages.Razor.WebPageRazorHost'](https://stackoverflow.com/questions/27576750/error-inheritance-security-rules-violated-by-type-system-web-webpages-razor-w) – Gustavo Russo Feb 20 '19 at 11:19
  • I was in the same situation. Don't comment these lines from Web.config. There might be multiple nuget packages having a conflict. In my case, System.Web.Mvc.Extensions.Mvc.4 and Microsoft.AspNet.Mvc were installed. On uninstalling the first nuget, all worked fine. – foo Apr 09 '19 at 02:38

0 Answers0