Visual studio compiles fine but still shows red lines

僤鯓⒐⒋嵵緔 提交于 2019-12-29 03:11:29

问题


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.

  1. Red Underlines in the code
  2. While cleaning or building the solution no error.
  3. red Underlines go away for some time after I build/clean the solution but comes back eventually.
  4. Because of this my intellisense stopped working.
  5. I can not right click to any component and go to its definition.

Any ideas?


回答1:


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)

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




回答2:


Visual Studio 2017:

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

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




回答3:


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.




回答4:


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.




回答5:


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




回答6:


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

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

devenv /Safemode



回答7:


I had this issue and it was related to ReSharper.

Solution steps for me:

1) Disable ReSharper

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

2) Build Solution

(Ctrl-Shift-B)

3) ReEnable ReSharper

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

Steve




回答8:


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

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.



回答9:


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.




回答10:


What works for me is deleting the IntelliSense indexfile.

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

It's filename is SolutionName.sdf

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




回答11:


This worked for me in Visual Studio Enterprise 2017:

  1. Navigate to Tools > Options > Text Editor > JavaSCript/TypeScript > Linting > General

  2. deselect "Enable ESLint"




回答12:


Simply refresh the proj/solution. It will get resolved.




回答13:


I've run into this as well and was able to return Visual Studio to it's normal state by doing the following -

  1. Identify the project that the red lined code comes from
  2. Remove the red line project from the references where it is being used (ProjectName\References - right click, add references, uncheck red line project)
  3. Build (you should get errors now)
  4. Re-add the project reference that was just removed
  5. Build Again
  6. Red lines should be removed and project should build!



回答14:


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.




回答15:


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!




回答16:


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

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




回答17:


Steps that work

  1. Open Solution and do a re build all
  2. Close Solution
  3. Open solution and do a clean
  4. Close solution
  5. Open solution and do a re build all
  6. Close and then open solution and it should be good. This works for me every time

Careful deleting some of these settings files as you will lose saved debug settings etc and it may do more damage than you realize




回答18:


I had the same problem with lots of red lines in several *cpp source files. Though the code compiled perfectly. None of the other solutions worked for me.

Changing the order of #include lines of a *.cpp-file could make the red lines dissapear - and reapper with the restored order.

Then I noticed a header file was included twice in a single *.cpp file. I removed the second one and - everything was fine.

Including a header file twice in the same *.cpp file seems to be no problem to the compiler but to the intellisense part.




回答19:


In my case with VS 2017, I have many "red lines" shown below all symbols defined in a third party library but my project can actually build without problem. I have tried all suggested solutions (like delete .VS folder, restart VS, etc.) but none of them working.

Finally, I fixed it and this is how: I open my app project's property page, then go to "C/C++ -> General -> Additional Include Directories", which is the place I put all needed third-party library header paths. I delete all the path (but save them somewhere), click "Ok" to confirm. Then I came back to the same setting, paste those path back, click "Ok" to confirm, then all those "red lines" disappear.



来源:https://stackoverflow.com/questions/21098333/visual-studio-compiles-fine-but-still-shows-red-lines

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!