简体   繁体   English

无效的Intellisense错误CS0103 ASP.NET网站“该名称在当前上下文中不存在”

[英]Invalid Intellisense error CS0103 ASP.NET Web Site “The name does not exist in the current context”

I have got a big ASP.NET Website (so no designer.cs files), which I lately have converted from VS2012 to VS2017. 我有一个很棒的ASP.NET网站(所以没有designer.cs文件),我最近已经从VS2012转换为VS2017。 Now in VS2017 dozens of Intellisense errors like 现在在VS2017中出现了几十个Intellisense错误

CS0103 The name 'DDLxyz' does not exist in the current context 
CS0103 The name 'CBxyz' does not exist in the current context 

appear in the error list. 出现在错误列表中。 These did not appear in VS2012. 这些没有出现在VS2012中。 These are no real errors, but invalid Intellisense errors, which I do know because of 这些都不是真正的错误,但无效的Intellisense错误,我知道因为

a) The site works. a)网站有效。 All the "not existing" controls work flawlessly. 所有“不存在”的控件都可以完美地工作。

b) The errors disappear from the error list when I select the filter "Build only", they appear when I select the filter "Build + Intellisense". b)当我选择过滤器“仅构建”时,错误从错误列表中消失,当我选择过滤器“Build + Intellisense”时,它们会出现。

c) Strange but true: when I double click such an error in the error list, the according aspx.cs file opens in VisualStudio and shortly thereafter, the errors concerning this file vanish from the list and also the red squiggly lines in the file vanish. c)奇怪但真实:当我在错误列表中双击这样的错误时,相应的aspx.cs文件在VisualStudio中打开,此后不久, 有关此文件的错误从列表中消失,文件中的红色波浪线也消失了。 So somehow VS must know that all these errors are invalid. 所以VS必须知道所有这些错误都是无效的。

What I've got from other similar questions here on SO: 我从SO上的其他类似问题中得到了什么:

  • Closing and reopening VS, cleaning the solution, rebuilding does not help. 关闭并重新打开VS,清理解决方案,重建无济于事。 In contrary: When I made the errors vanish by applying point (c) above and do a clean solution and rebuild, the errors show up again. 相反:当我通过应用上面的点(c)使错误消失并做一个干净的解决方案并重建时,错误再次出现。 Sometimes. 有时。

  • A workaround recommends 'Use the "Build only" filter' in the error list. 解决方法建议在错误列表中使用“仅构建”过滤器。 This works, but i am not content with it. 这有效,但我不满足于此。 I'd like to have other Intellisense errors shown. 我想显示其他Intellisense错误。

  • A workaround recommends disabling the error CS0103 via the filter options. 解决方法建议通过过滤器选项禁用错误CS0103。 I found no way to do this in my version of VS2017 v 15.9.14. 在我的VS2017 v 15.9.14版本中,我发现无法做到这一点。 I found no way to disable just CS0103 in a website project. 我发现在网站项目中没有办法禁用CS0103。 The filter options do only show "error, warning, message" but no single error numbers. 过滤器选项仅显示“错误,警告,消息”,但没有单个错误号。
    (If it was possible, I wouldn't like the solution too much, as there might be real errors of this kind be filtered away. But I'd nevertheless take this workaround.) (如果有可能的话,我不太喜欢这个解决方案,因为可能会有这种真正的错误被过滤掉。但是我仍然会采取这种解决方法。)

  • Some recommend to rebuild the designer.cs file. 有人建议重建designer.cs文件。 But this is a website project, there are no designer.cs files at all. 但这是一个网站项目,根本没有designer.cs文件。

I don't want these invalid errors to show up in the error list. 我不希望这些无效错误显示在错误列表中。

If there is no other way, I would also use a possibility to switch off all CS0103 errors for this project. 如果没有别的办法,我也可以关闭这个项目的所有CS0103错误。

Delete your .vs folder and then rebuild the solution. 删除.vs文件夹,然后重建解决方案。 That should remove all those Intellisense errors. 这应该删除所有那些Intellisense错误。

Assuming your VS2012 and VS2017 are in the same machine. 假设您的VS2012和VS2017在同一台机器上。

You can try: 你可以试试:

1.Navigate to the folder where WebsiteName.sln exists, since it was created in VS2012, it should have a xx.suo file in that directory. 1.导航到WebsiteName.sln存在的文件夹,因为它是在VS2012中创建的,它应该在该目录中有一个xx.suo文件。 And after you open it in VS2017, it will also have a hidden .vs folder. 在VS2017中打开它之后,它还会有一个隐藏的 .vs文件夹。

2.Close all VS instances and delete the .vs folder and xx.suo file 2.关闭所有VS实例并删除.vs文件夹和xx.suo文件

3.Clean the VS cache. 3.清理VS缓存。 C:\\users[USER]\\AppData\\Local\\Microsoft\\VisualStudio\\12.0 and C:\\users[USER]\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0 . C:\\users[USER]\\AppData\\Local\\Microsoft\\VisualStudio\\12.0 and C:\\users[USER]\\AppData\\Roaming\\Microsoft\\VisualStudio\\12.0 I also delete the 15.0 for VS2017, after that reopen vs to check if this issue go away. 我也删除了VS2017的15.0,之后重新打开vs来检查这个问题是否消失。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET 核心 Web API - 错误 CS0103 当前上下文中不存在名称“FetchToken” - ASP.NET Core Web API - Error CS0103 The name 'FetchToken' does not exist in the current context FluentValidation“错误 cs0103 当前上下文中不存在名称‘x’”.asp.net 核心 2.1 - FluentValidation "Error cs0103 the name 'x' does not exist in the current context" .asp.net core 2.1 ASP.NET 内核 Web API - 如何解决错误 CS0103 名称“分数”在当前上下文中不存在 - ASP.NET Core Web API - How to resolve Error CS0103 The name 'score' does not exist in the current context 错误 CS0103:当前上下文中不存在名称“_context” - Error CS0103: The name '_context' does not exist in the current context 错误 CS0103:当前上下文中不存在名称“currentScreen”(CS0103) - Error CS0103: The name 'currentScreen' does not exist in the current context (CS0103) 错误CS0103:名称“ TimeSpan”在当前上下文(CS0103)(testingProgram)中不存在? - Error CS0103: The name 'TimeSpan' does not exist in the current context (CS0103) (testingProgram)? 错误cs0103名称'IEnumerator'在当前上下文中不存在 - error cs0103 The Name 'IEnumerator' does not exist in the current context 错误CS0103:名称“ HttpUtility”在当前上下文中不存在 - error CS0103: The name `HttpUtility' does not exist in the current context "错误 CS0103:当前上下文中不存在名称“AssetPreview”" - error CS0103: The name 'AssetPreview' does not exist in the current context 错误CS0103当前上下文中不存在名称“图像” - Error CS0103 The name 'Image' does not exist in the current context
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM