2010-11-12 33 views
14

我的Razor视图失败,出现以下错误编译:剃刀页面都给人一种编译错误与System.Web.Helpers未找到

Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. 

Compiler Error Message: CS0234: The type or namespace name 'Helpers' does not exist in the namespace 'System.Web' (are you missing an assembly reference?) 

我System.Web.Helpers添加为参考我的项目,所以我不知道我还需要做什么。添加引用后,我也尝试了一次干净的重建,并且没有任何改变。

我错过了什么?

+1

是这个项目从以前版本的MVC的提升呢? – 2010-11-12 22:30:03

+0

http://stackoverflow.com/questions/267006/could-not-load-file-or-assembly-system-web-mvc/4801390#4801390 – user202448 2011-02-17 18:07:47

回答

30

啊哈想通了。我需要添加

<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> 

到Web.config中的<assemblies>节!

+0

你能告诉我它是如何自动添加到web配置文件中的吗? – 2013-04-02 13:15:01

+1

我在web.config中看不到'assembly'部分。是否有示例文件? – 2013-07-06 22:32:43

+0

将该行放在 SushiGuy 2013-10-29 15:42:04

3

web.config行应该在这里:

<configuration> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0"> 
     <assemblies> 
      <add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />