Wednesday, June 10, 2015

How to solve problem "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."

How to solve problem "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."

This error happens after add Razor engine into ASP.NET MVC 4 project by nuget package.
https://github.com/Antaris/RazorEngine

I fixed this problem by remove following part from web.config
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Razor" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>

Reason:
Default ASP.NET MVC 4 razor engine is version 2, and nuget for RazorEngine project is version 3.

No comments:

Post a Comment