解决报错:类型“System.Object”在未被引用的程序集中定义。必须添加对程序集“System.Runtime, Version=4.0.0.0, Culture=neutral, Public

Razor视图引擎中,使用部分视图编译报错

 类型“System.Object”在未被引用的程序集中定义。必须添加对程序集“System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”的引用

 

查找网上一些解决方案,在微软官网找到同样问题

 

 最后解决方案:

 

在web.config文件system.web/compilation节点添加配置节点

 

<compilation debug="true" targetFramework="4.5" > <assemblies> <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </assemblies> </compilation>