gpt4 book ai didi

c# - 发布ASP .NET MVC项目时的“The type or namespace name could not be found”

转载 作者:太空宇宙 更新时间:2023-11-03 17:30:47 24 4
gpt4 key购买 nike

我是C#ASP .NET MVC的新手,所以我不确定很多事情。但是我在新公司继承了这个项目,而我只是试图构建我在这里开始工作时存储在接管的计算机上的文件。我敢肯定,自从最后一个家伙离开以来,没有人碰过这些文件,所以我认为代码应该没有问题,因为该站点现在可以正常使用并且可以正常工作。

但是,当我尝试将这些文件发布到登台站点(出于测试目的)时,我遇到了一堆相同的错误(找出错误中给出的完整路径),并且该项目无法发布。

    Error   77  The type or namespace name 'Controller' could not be found (are you missing a using directive or an assembly reference?)    \Controllers\AccountController.cs   15  38  Project
Error 99 The type or namespace name 'HttpGetAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 17 10 Project
Error 100 The type or namespace name 'HttpGet' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 17 10 Project
Error 115 The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 18 16 Project
Error 182 The type or namespace name 'HttpPostAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 40 10 Project
Error 183 The type or namespace name 'HttpPost' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 40 10 Project
Error 186 The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 41 16 Project
Error 257 The type or namespace name 'HttpGetAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 78 10 Project
Error 258 The type or namespace name 'HttpGet' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 78 10 Project
Error 265 The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 79 16 Project
Error 284 The type or namespace name 'HttpPostAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 89 10 Project
Error 285 The type or namespace name 'HttpPost' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 89 10 Project
Error 291 The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 90 16 Project
Error 332 The type or namespace name 'AuthorizeAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 112 10 Project
Error 333 The type or namespace name 'Authorize' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 112 10 Project
Error 335 The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 113 16 Project
Error 343 The type or namespace name 'AuthorizeAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 121 10 Project
Error 344 The type or namespace name 'Authorize' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 121 10 Project
Error 345 The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 122 16 Project
Error 363 The type or namespace name 'HttpGetAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 150 10 Project
Error 364 The type or namespace name 'HttpGet' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 150 10 Project
Error 365 The type or namespace name 'AuthorizeAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 151 10 Project
Error 366 The type or namespace name 'Authorize' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 151 10 Project
Error 367 The type or namespace name 'ActionResult' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 152 16 Project
Error 377 The type or namespace name 'HttpGetAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 162 10 Project
Error 378 The type or namespace name 'HttpGet' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 162 10 Project
Error 379 The type or namespace name 'AuthorizeAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 163 10 Project
Error 380 The type or namespace name 'Authorize' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 163 10 Project
Error 384 The type or namespace name 'ActionNameAttribute' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 164 10 Project
Error 385 The type or namespace name 'ActionName' could not be found (are you missing a using directive or an assembly reference?) \Controllers\AccountController.cs 164 10 Project

对于项目中的许多文件,还有很多同类错误。错误的显示方式使我相信这是一个容易解决的问题,因为它们几乎都是相同的错误。

任何人都知道如何解决这些错误,以便我可以成功地构建此项目?

最佳答案

您需要确保您的项目具有对所有必需 namespace 的引用。例如,HttpGetAttribute和该列表中的所有其他名称实际上属于System.Web.Mvc

如果您在VS中打开该项目的引用“文件夹”,则可能会在某些引用旁边看到警告标志。删除它们并重新添加它们。

要重新添加引用,请首先将其删除,然后右键单击“引用”文件夹,然后单击“添加引用”。单击左侧的Assembles treeview项目,然后在右侧的搜索框中键入System.Web.Mvc,它将 pop 该DLL版本的列表。

为了将来引用,每当您看到类似这样的内容时,解决该问题的最佳方法是只搜索无法找到的类的名称,后跟“MSDN”,在这种情况下,您将搜索“HttpGetAttribute msdn”。这将告诉您需要包括哪个引用。

关于c# - 发布ASP .NET MVC项目时的“The type or namespace name could not be found”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28745531/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com