Skip to main content
 首页 » 编程设计

c#之CS0234 : The type or namespace name 'WebPages' does not exist in the namespace 'System.Web' (are you missing an assembly reference )

2024年01月13日27jillzhang

我构建了一个从数据库读取数据的简单 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 进行“Copy Local True”并再次部署。

但是我注意到第二台机器上没有安装 Microsoft .Net Framework 4.5 Multi-Targeting Pack。

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

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

如果有人能对此有所了解,我们将不胜感激。

谢谢

请您参考如下方法:

确保所有引用都添加到项目中,并在将其部署到第二台机器之前复制本地 True,这可能没有安装组件。

感谢 Mason 和 Saj。