views:

1087

answers:

3

I wonder, why the hell... did the VS team consider that NOT finding a project reference as a non crucial thing?

The referenced component 'X' could not be found. should be considered an error... and nothing else.

Is there a way (without turning 'Treat all warnings as errors' on) to get this warning as an error in VS2008?

+2  A: 

That warning comes from the project system, not the compiler. The project system doesn't know whether or not the reference will actually be needed when the code is compiled. I've run into several cases (all involving multiple platforms and conditional compilation) where this features allows you to maintain a single project file when you might otherwise have to split into one file per configuration.

There is an option to "treat warnings as errors" -- you should be able to find it in the project configuration screen.

Curt Hagenlocher
Well, the question was: is there some way to just treat "that" warning as an error in VS... I really can't treat all warnings as errors at this time.
kitofr
There's a way to exclude specific warning numbers from being treated as errors -- but I think it only works in that direction. So you'd have to say "treat all warnings as errors except for #1, #2 and #3.
Curt Hagenlocher
Ok, that's a bit stupid... but ill consider it, tnx.
kitofr
Well, your code really shouldn't be generating a lot of warnings. And you can also disable certain warnings entirely if they're not useful to you.
Curt Hagenlocher
Well as I said, I would love to turn on treat all warnings as error, but that's not possible. So, ill have to settle for something in between.
kitofr
A: 

Why do you think it should be any error? If you had actually used anything in the assembly, then you'd get an error where you use it. So far, all you've said is "I may need this file", and VS is responding "Well, I hope you don't, because I can't find it".

James Curran
Nope... actually gets through compilation as Success...
kitofr
Then you are NOT using anything in that assembly... which is why I said "get an error *where you use it*."
James Curran
Well, I was.. but in a web-site. And as the msbuild doesn't compile that in the same manner as for example asp.compile would... u won't notice.
kitofr
A: 

This warning does my head in.

I have a project with six configurations - each configuration uses a different version of a particular referenced DLL, and so the references are conditional (by hacking the project file, as I cannot find a way to do it through the VS GUI).

The five references that are not used for the current configuration, despite being present on disk, are always displayed with an exclamation mark in the GUI, and this warning (which does not appear to have a warning ID) is displayed.

I would love to be able to "fix" Visual Studio so that it could determine that due to the configuration currently being built, it is irrelevant that this reference may or may not be present (even though it is present).

Seriously, sometimes Microsoft's obtuseness drives me up the wall.

related questions