Visual Studio 2010 Improperly underlining code/comments with red error line when there is no error

穿精又带淫゛_ 提交于 2019-12-07 09:08:30

问题


I am working on a rather large project, and I am having strange problems with the IDE in terms of error checking and somewhat with IntelliSense.

Usually if I were to type something boneheaded, like "int a = "aa";", it would underline "aa" in red. However I am seeing VS do this to random parts of my code when I make insignificant changes.

For example:

/*
     Some comment here, just going to stretch it out for my example..
*/

int proto1();
int proto2();

If I make changes to other parts of the project, sometimes random functions will get underlined, and even part of a comment. Like just 30 minutes ago it underlined the equivalent of half of that comment beginning in the middle of the word "comment", also it underlined all of int proto1(); and part of int proto2();

I would post screenshots but I am bound by contract not to disclose any work, and I can't easily replicate it in smaller projects.

I don't understand why it does this. When I compile the project, any fake errors and underlining it did goes away and it compiles fine. The point though, is there are no errors. It's making up random errors and underlining random lines/words/half words. I would also like to note that there seems to be a large delay in loading new intellisense information, almost by 2-3 minutes or longer.

I'll try and reproduce it in an unrelated project and post here if I can. However, any help would be appreciated.

Thanks!

*Edit: Forgot to note that hitting the space key several times will on occasion correct the errors however this isn't reliable and does not always work.


回答1:


Intellisense sometimes can really get stuck with complicated code. I guess until VS2012 release comes out, there's nothing we can do.

There's however one trick that I'm using if this happens - switch your build configuration Debug -> Release and then back again. You don't have to wait, you can just click two times on this drop-down box. It should refresh IS cache and make red error underlines dissappear.




回答2:


Intellisense is often off, but make sure you have latest updates installed. I just installed sp1 yesterday and lot of Intellisense issues went way.




回答3:


I see this is a stale question but some may find this helpful.

I just had this same issue. I tried many of the solutions outlined here and elsewhere. I finally tried running Visual Studio as another user (Shift Right Click Run As Different User) and the issue did not present. I then logged into my computer as another user and deleted the profile of the user I was having the issue with.

If your profile is important to you or there is information within it that is important I highly recommend backing up relevant information first. If you don't understand what information you profile contains make sure you do prior to deleting it.

1) Log in as different user (with admin privileges) than you want to delete

2) Open Properties for Computer

3) Advanced system settings (on the left side)

4) Settings for User Profiles (in the middle)

5) Select the profile you want to delete and click the delete button

6) Reboot

Credit to: https://superuser.com/questions/63017/how-do-i-delete-a-user-profile-on-a-windows-7-machine-that-is-part-of-a-domain




回答4:


I had the same issue, and in my case it was mostly related to library functions and types defined in libraries. This one fixed it for me:

Open command line parameters. You can use following to reach there: Project > ProjectName Properties > Configuration Properties > Linker > Command Line

In the Additional Options box at the bottom add /I "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include"

You will of course need the correct path where Visual Studio is installed.

Bingo! I hope it works for you too. :)



来源:https://stackoverflow.com/questions/9729621/visual-studio-2010-improperly-underlining-code-comments-with-red-error-line-when

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