Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio "Organize Usings | Remove and Sort" falsely reports error

Tags:

In various code files of various projects, Visual Studio sometimes gives an error message when I tell it to remove and sort the usings of the code file. The message:

"Your project or one of its references does not currently build. If you continue with this operation, required usings may be removed."

However, this is not true. Required usings are not removed when telling VS to continue, and the project does build.

I have Googled this issue, looked in MSDN, and tried to figure out why I get this on certain code files but not others, but no no avail.

Has anyone else encountered this, and if so, any ideas what this is about?

Ps. I am running VS 2012 Ultimate, but I saw this from at least 2005.

like image 653
IamIC Avatar asked May 07 '13 06:05

IamIC


1 Answers

This error message can come up erroneously, and is a known issue documented out on Microsoft Connect:

http://connect.microsoft.com/VisualStudio/feedback/details/785457/remove-unused-usings-falsely-reports-that-project-does-not-build-for-certain-files

It will not be fixed with the current MSBuild compiler, but will be fixed with Roslyn.

Workaround:

You can disable the warning message by going to Tools->Options->Text Editor->C#->Advanced->"Warn if build errors exist when organizing usings".

Keep in mind this has the downside that it won't protect you any more if your solution really does not build.

like image 92
Steve Cadwallader Avatar answered Oct 06 '22 23:10

Steve Cadwallader