views:

413

answers:

4

VS2008/C# newbie here.

If I open our project, have no code files open, and hit Build Solution it'll show about half a dozen errors. Fine. When I start double-clicking open the individual code files (or double click on the error line) more errors start to crop up, and not necessarily about the file that I just opened. It seems like Build Solution is not doing a complete build. Is this normal behavior? We've got 4 people working on different code files in the same project and some will see different set of errors than others. It's annoying. Is there a setting or something we're missing?

Edit: Sorry I wasn't more specific. It's a Visual C# Class Library project with 19 CS files with 1 to 3 classes in each file.

A: 

Have you tried using Build All vs Build? A build all command will actually compile your entire solution. Do you have multiple projects within the solution?

It might also be related to how you are referencing other assemblies. What is your project structure?

Chris Lively
Nope, not a Web Application Project. Visual C# Class Library project with 19 CS files with 1 to 3 classes in each file.
SauerC
Don't get the Build All option, just Build Solution or Build <Project Name>. It's a single project right now. All the classes exists under a single namespace and the only references we're using are all under the System namespace.
SauerC
A: 

If you're using ASP.NET MVC, I've run into a problem where an error on one View page will cause a large number of other errors that cause the project not to build. If I locate and fix the error on the View, everything else just corrects itself, and the whole project builds.

Mark Struzinski
+3  A: 

I'd have to see to be sure, but I think what is happening is that you're seeing the compiler errors when you first build, and then as you open files, you get additional warnings (yellow icon) or errors (red x) specific to the file. Also, there is a setting to only show the first n errors, so if you have over whatever that threshold is, it could have this behavior.

Typically when you have a bunch of errors like this, there's some common cause that, once addressed, will fix the rest. For example, a missing reference or something like that.

Daniel
A: 

I see the same problem with #warning. If I search the solution for #warning, I find 16 lines in 13 files. If I Rebuild Solution with no files open I only see 3 warnings in the error list (there are 3 projects that have warnings). Any files that are open will also report their warnings, and if any file that has warnings is opened, they show up in the error list as well.

If I look at Output, the warnings are correctly reported there. I have one project that has 14 warnings, but only one shows up if no files are open. After some more investigation, it seems that the warnings from the last file in the project are reported: I added a warning to a file in one of the projects that only had one warning, and the new warning showed up (if it was compiled after the file that had the other warning).