CS0234:名称空间“System.Web”中不存在类型或命名空间名称“WebPages”(您是否缺少程序集引用?)

时间:2015-05-04 23:40:04

标签: c# asp.net visual-studio-2012 asp.net-web-api

我构建了一个简单的Web API项目,用于从数据库中读取数据。我正在使用VS 2012,它在我的win7机器上工作正常。我已将Web应用程序发布到本地文件夹,并将其部署到另一台win7计算机上。但是,在尝试访问第二台计算机上的URL时,它会给出上述错误。

这是错误的一行:

**

 Compilation Error
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 'WebPages' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

Source Error:

Line 30:       <namespaces>
Line 31:         <add namespace="System.Web.Routing" />
Line 32:         <add namespace="System.Web.WebPages" />
Line 33:       </namespaces>
Line 34:     </pages>

Source File: c:\inetpub\wwwroot\rcItems\Web.config    Line: 32

**

我已检查过两台计算机上都安装了Microsoft .NET Framework 4.5.1。

我曾尝试在我的项目中为System.Web.dll“复制Local True”并重新部署。

但是我注意到第二台计算机上没有安装Microsoft .Net Framework 4.5多目标包。

此外,此文件(和文件夹)不在第二台机器上:

C:\ Program Files(x86)\ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5 \ System.Web.dll

如果有人能够对此有所了解,那将非常感激。

由于

1 个答案:

答案 0 :(得分:-2)

确保所有引用都添加到项目中并复制Local True,然后再将其部署到可能没有安装组件的第二台计算机上。

感谢Mason和Saj。