Visual Studio编译精细但仍显示红线

时间:2023-01-16 22:00:16

I am using VS 2012 and it was working all fine until I started observing some funny behavior. When I open my code it shows red Underlines which we usually see when there is an error in our code. Surprisingly, code compiles all fine. I have made following observations that are not normal at all.

我正在使用VS 2012,它一切正常,直到我开始观察一些有趣的行为。当我打开我的代码时,它显示红色下划线,当我们的代码中出现错误时,我们通常会看到这些下划线。令人惊讶的是,代码编译得很好。我做了以下完全不正常的观察。

  1. Red Underlines in the code
  2. 代码中的红色下划线
  3. While cleaning or building the solution no error.
  4. 清洁或构建解决方案时没有错误。
  5. red Underlines go away for some time after I build/clean the solution but comes back eventually.
  6. 红色下划线在我构建/清理解决方案后会消失一段时间但最终会回来。
  7. Because of this my intellisense stopped working.
  8. 因此我的intellisense停止工作。
  9. I can not right click to any component and go to its definition.
  10. 我无法右键单击任何组件并转到其定义。

Any ideas?

有任何想法吗?

13 个解决方案

#1


31  

Delete the contents of the temporary ASP.NET folder and then rebuild. It'll either be in your user folder (for IIS Express - \AppData\Local\Temp\Temporary ASP.NET Files) or the Windows directory (for IIS - C:\Windows\Microsoft.Net\Framework\vx.xx\Temporary ASP.NET Files)

删除临时ASP.NET文件夹的内容,然后重建。它将位于您的用户文件夹(对于IIS Express - \ AppData \ Local \ Temp \ Temporary ASP.NET Files)或Windows目录(对于IIS - C:\ Windows \ Microsoft.Net \ Framework \ vx.xx \临时ASP.NET文件)

Paths are off the top of my head and may not be correct

路径是我的头顶,可能不正确

#2


41  

Visual Studio 2017:

Visual Studio 2017:

Closing Visual Studio and removing the .vs folder located in the solution directory worked for me.

关闭Visual Studio并删除解决方案目录中的.vs文件夹对我有用。

This folder has a hidden attribute. You may need to change settings in folder options to show hidden files.

此文件夹具有隐藏属性。您可能需要更改文件夹选项中的设置以显示隐藏文件。

#3


8  

Just had this problem while working with a solution created in Visual Studio 2012 but running in 2013. I closed Visual Studio, deleted all \bin and \obj directories and the problem was gone.

在使用在Visual Studio 2012中创建但在2013年运行的解决方案时遇到此问题。我关闭了Visual Studio,删除了所有\ bin和\ obj目录,问题就消失了。

#4


7  

I know this is old but in case people find this thread like I did from google. I had this problem after resolving some conflicts from svn. The solution has several projects in it and I resolved some conflicts in a few different projects. I did a Build -> Clean Solution followed by a Build -> Rebuild Solution and everything was good again.

我知道这是旧的,但万一人们发现这个线程就像我从谷歌那样。在解决了svn的一些冲突之后,我遇到了这个问题。该解决方案中有几个项目,我在几个不同的项目中解决了一些冲突。我做了一个Build - > Clean Solution,然后是Build - > Rebuild Solution,一切都很好。

#5


5  

Do you have any plugins installed like resharper? I had an issues with a bad plugin.

你有像resharper一样安装的插件吗?我有一个坏插件的问题。

Try running visual studio in safe mode, to prevent plugins from running.

尝试在安全模式下运行visual studio,以防止插件运行。

devenv /Safemode

#6


4  

For me this issue got fixed when I Unloaded and Reloaded the project again. I worked for me , hope it works for you too :)

对我来说,当我再次卸载并重新加载项目时,此问题得到修复。我为我工作,希望它也适合你:)

#7


2  

In vs2013 I solved this problem by deleting all of my obj/bin folders across all projects. The issue was probably due to solution configurations that I had deleted, but hadn't been cleaned up properly, as doing a Build -> Clean Solution doesn't remove the old outputs from the obj/bin folders.

在vs2013中,我通过删除所有项目中的所有obj / bin文件夹解决了这个问题。问题可能是由于我已删除但尚未正确清理的解决方案配置,因为执行Build - > Clean Solution不会从obj / bin文件夹中删除旧输出。

#8


1  

What works for me is deleting the IntelliSense indexfile.

对我有用的是删除IntelliSense索引文件。

The IntelliSense-file is in the same directory as you solution.

IntelliSense文件与解决方案位于同一目录中。

It's filename is SolutionName.sdf

它的文件名是SolutionName.sdf

Just delete this file, open you solution again, and IntelliSense will start rebuilding its indexfile. After that the problem will be gone.

只需删除此文件,再次打开解决方案,IntelliSense将开始重建其索引文件。之后问题就会消失。

#9


1  

I had this issue and it was related to ReSharper.

我有这个问题,它与ReSharper有关。

Solution steps for me:

我的解决方案步骤:

1) Disable ReSharper

1)禁用ReSharper

VisualStudio\Tools\Options\ReSharper Ultimate\General\Suspend Now

2) Build Solution

2)构建解决方案

(Ctrl-Shift-B)

3) ReEnable ReSharper

3)ReEnable ReSharper

VisualStudio\Tools\Options\ReSharper Ultimate\General\Resume Now

Steve

史蒂夫

#10


0  

Perhaps It is late to add but hope it might still help someone. I had similar problem when I was seeing lot of red squiggles in couple of files. I tried all answers proposed above but nothing seemed to work. The moment I started browsing through the classes, structures in other files for which complaining files had references, problem disappeared. It seemed intellisense was not able to resolved dependencies on its own for some reason.

也许现在添加已经很晚了,但希望它可能仍然可以帮到某些人。当我在几个文件中看到很多红色波浪线时,我遇到了类似的问题。我尝试了上面提出的所有答案,但似乎没有任何效果。当我开始浏览类,其他文件中的抱怨文件引用的结构时,问题就消失了。似乎intellisense由于某种原因无法自行解决依赖关系。

#11


0  

For me, I had at one time enabled fusion logging to debug some assembly dependency errors (fuslogvw from CMD prompt). That was months ago and I had been experiencing much slower build times (5-7 minutes) since then. I had also forgotten entirely that I had left them enabled. These logs were my bottle neck and disabling them has made iterating much faster. Hope this helps someone!

对我来说,我曾经一度启用了融合日志来调试一些程序集依赖性错误(来自CMD提示符的fuslogvw)。那是几个月前,我从那时起经历了更慢的构建时间(5-7分钟)。我也完全忘记了我让它们启用了。这些日志是我的瓶颈,禁用它们使迭代更快。希望这有助于某人!

#12


0  

I ran into this problem with the latest Visual Studio 2017.
Also the debug version of my program was running painfully slow.

我使用最新的Visual Studio 2017遇到了这个问题。而且我的程序的调试版运行速度非常慢。

I deleted the Solution file .sln and created a new one.

我删除了解决方案文件.sln并创建了一个新文件。

#13


0  

If you are using Resharper like me, you may delete resharper cache following by this link: https://www.jetbrains.com/help/resharper/Configuring_Caches_Location.html

如果您使用像我这样的Resharper,您可以通过以下链接删除resharper缓存:https://www.jetbrains.com/help/resharper/Configuring_Caches_Location.html

To specify the location for caches

1. Open the Environment | General page of ReSharper options.
2. Use the Save solution caches in to select the location for cache files:
3. User local settings folder to store them in the following directory: %LOCALAPPDATA%\JetBrains\Transient
4.System TEMP folder to store them in the following directory: %TEMP%\ReSharperCache
5. Solution folder to store them in the root folder of the current solution
6. Custom folder to choose a custom location for ReSharper cache files.
7. Click Save to apply the modifications and let ReSharper choose where to save them, or save the modifications to a specific settings layer using the Save To drop-down list. For more information, see managing and sharing resharper settings.
8. Reopen your solution for the changes to take effect.

#1


31  

Delete the contents of the temporary ASP.NET folder and then rebuild. It'll either be in your user folder (for IIS Express - \AppData\Local\Temp\Temporary ASP.NET Files) or the Windows directory (for IIS - C:\Windows\Microsoft.Net\Framework\vx.xx\Temporary ASP.NET Files)

删除临时ASP.NET文件夹的内容,然后重建。它将位于您的用户文件夹(对于IIS Express - \ AppData \ Local \ Temp \ Temporary ASP.NET Files)或Windows目录(对于IIS - C:\ Windows \ Microsoft.Net \ Framework \ vx.xx \临时ASP.NET文件)

Paths are off the top of my head and may not be correct

路径是我的头顶,可能不正确

#2


41  

Visual Studio 2017:

Visual Studio 2017:

Closing Visual Studio and removing the .vs folder located in the solution directory worked for me.

关闭Visual Studio并删除解决方案目录中的.vs文件夹对我有用。

This folder has a hidden attribute. You may need to change settings in folder options to show hidden files.

此文件夹具有隐藏属性。您可能需要更改文件夹选项中的设置以显示隐藏文件。

#3


8  

Just had this problem while working with a solution created in Visual Studio 2012 but running in 2013. I closed Visual Studio, deleted all \bin and \obj directories and the problem was gone.

在使用在Visual Studio 2012中创建但在2013年运行的解决方案时遇到此问题。我关闭了Visual Studio,删除了所有\ bin和\ obj目录,问题就消失了。

#4


7  

I know this is old but in case people find this thread like I did from google. I had this problem after resolving some conflicts from svn. The solution has several projects in it and I resolved some conflicts in a few different projects. I did a Build -> Clean Solution followed by a Build -> Rebuild Solution and everything was good again.

我知道这是旧的,但万一人们发现这个线程就像我从谷歌那样。在解决了svn的一些冲突之后,我遇到了这个问题。该解决方案中有几个项目,我在几个不同的项目中解决了一些冲突。我做了一个Build - > Clean Solution,然后是Build - > Rebuild Solution,一切都很好。

#5


5  

Do you have any plugins installed like resharper? I had an issues with a bad plugin.

你有像resharper一样安装的插件吗?我有一个坏插件的问题。

Try running visual studio in safe mode, to prevent plugins from running.

尝试在安全模式下运行visual studio,以防止插件运行。

devenv /Safemode

#6


4  

For me this issue got fixed when I Unloaded and Reloaded the project again. I worked for me , hope it works for you too :)

对我来说,当我再次卸载并重新加载项目时,此问题得到修复。我为我工作,希望它也适合你:)

#7


2  

In vs2013 I solved this problem by deleting all of my obj/bin folders across all projects. The issue was probably due to solution configurations that I had deleted, but hadn't been cleaned up properly, as doing a Build -> Clean Solution doesn't remove the old outputs from the obj/bin folders.

在vs2013中,我通过删除所有项目中的所有obj / bin文件夹解决了这个问题。问题可能是由于我已删除但尚未正确清理的解决方案配置,因为执行Build - > Clean Solution不会从obj / bin文件夹中删除旧输出。

#8


1  

What works for me is deleting the IntelliSense indexfile.

对我有用的是删除IntelliSense索引文件。

The IntelliSense-file is in the same directory as you solution.

IntelliSense文件与解决方案位于同一目录中。

It's filename is SolutionName.sdf

它的文件名是SolutionName.sdf

Just delete this file, open you solution again, and IntelliSense will start rebuilding its indexfile. After that the problem will be gone.

只需删除此文件,再次打开解决方案,IntelliSense将开始重建其索引文件。之后问题就会消失。

#9


1  

I had this issue and it was related to ReSharper.

我有这个问题,它与ReSharper有关。

Solution steps for me:

我的解决方案步骤:

1) Disable ReSharper

1)禁用ReSharper

VisualStudio\Tools\Options\ReSharper Ultimate\General\Suspend Now

2) Build Solution

2)构建解决方案

(Ctrl-Shift-B)

3) ReEnable ReSharper

3)ReEnable ReSharper

VisualStudio\Tools\Options\ReSharper Ultimate\General\Resume Now

Steve

史蒂夫

#10


0  

Perhaps It is late to add but hope it might still help someone. I had similar problem when I was seeing lot of red squiggles in couple of files. I tried all answers proposed above but nothing seemed to work. The moment I started browsing through the classes, structures in other files for which complaining files had references, problem disappeared. It seemed intellisense was not able to resolved dependencies on its own for some reason.

也许现在添加已经很晚了,但希望它可能仍然可以帮到某些人。当我在几个文件中看到很多红色波浪线时,我遇到了类似的问题。我尝试了上面提出的所有答案,但似乎没有任何效果。当我开始浏览类,其他文件中的抱怨文件引用的结构时,问题就消失了。似乎intellisense由于某种原因无法自行解决依赖关系。

#11


0  

For me, I had at one time enabled fusion logging to debug some assembly dependency errors (fuslogvw from CMD prompt). That was months ago and I had been experiencing much slower build times (5-7 minutes) since then. I had also forgotten entirely that I had left them enabled. These logs were my bottle neck and disabling them has made iterating much faster. Hope this helps someone!

对我来说,我曾经一度启用了融合日志来调试一些程序集依赖性错误(来自CMD提示符的fuslogvw)。那是几个月前,我从那时起经历了更慢的构建时间(5-7分钟)。我也完全忘记了我让它们启用了。这些日志是我的瓶颈,禁用它们使迭代更快。希望这有助于某人!

#12


0  

I ran into this problem with the latest Visual Studio 2017.
Also the debug version of my program was running painfully slow.

我使用最新的Visual Studio 2017遇到了这个问题。而且我的程序的调试版运行速度非常慢。

I deleted the Solution file .sln and created a new one.

我删除了解决方案文件.sln并创建了一个新文件。

#13


0  

If you are using Resharper like me, you may delete resharper cache following by this link: https://www.jetbrains.com/help/resharper/Configuring_Caches_Location.html

如果您使用像我这样的Resharper,您可以通过以下链接删除resharper缓存:https://www.jetbrains.com/help/resharper/Configuring_Caches_Location.html

To specify the location for caches

1. Open the Environment | General page of ReSharper options.
2. Use the Save solution caches in to select the location for cache files:
3. User local settings folder to store them in the following directory: %LOCALAPPDATA%\JetBrains\Transient
4.System TEMP folder to store them in the following directory: %TEMP%\ReSharperCache
5. Solution folder to store them in the root folder of the current solution
6. Custom folder to choose a custom location for ReSharper cache files.
7. Click Save to apply the modifications and let ReSharper choose where to save them, or save the modifications to a specific settings layer using the Save To drop-down list. For more information, see managing and sharing resharper settings.
8. Reopen your solution for the changes to take effect.