Error: Inheritance security rules violated by type: 'System.Web.WebPages.Razor.WebPageRazorHost'

后端 未结 6 972
独厮守ぢ
独厮守ぢ 2020-12-15 03:09

Out of nowhere my ASP.NET MVC 4 solution gives me this error:

Inheritance security rules violated by type: \'System.Web.WebPages.Razor.WebPageRazorHos

6条回答
  •  隐瞒了意图╮
    2020-12-15 03:55

    Your project references are in turn linked to different versions of Microsoft.AspNet.Razor library, that are incompatibles between them.

    Your stack trace points to System.Web.WebPages dll, which is probably linking to a version of the Microsoft.AspNet.Razor older that the one referenced by other NuGet package (for example Microsoft.AspNet.Mvc).

    To fix the problem:

    1. If you are directly referencing the System.Web.WebPages, remove the reference and start using the System.Web.WebPages NuGet package
    2. If you are already using the System.Web.WebPages NuGet package, update it to the same version of the Microsoft.AspNet.Razor package that you are already using in your project.

    This will fix your current error, but probably will result in a new one appearing, especially if you are migrating or mixing packages between Microsoft.AspNet.Mvc versions. In this case, you need to sync the versions of all your NuGet packages related to MVC.

提交回复
热议问题