15310

Why is “The referenced component 'X' could not be found.” considered a warning?

Question:

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.

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

Answer1:

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.

Answer2:

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 <em>may</em> need this file", and VS is responding "Well, I hope you don't, because I can't find it".

Answer3:

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.

Recommend

  • Send email from Outlook Express in C#
  • Using forward declarations for built in datatypes
  • Any good way for getting a single instance instead of using Singleton (in C#)
  • Spring MVC redirect with custom http headers
  • Crafting a LINQ based solution to determine if a set of predicates are satisfied for a pair of colle
  • Creating an Order Column for encrypted data
  • 'include' of functions in groovy scripts
  • crash in __tcf_0
  • Using $compile in a directive triggers AngularJS infinite digest error
  • For loop with if condition on multiple R functions
  • Find group of records that match multiple values
  • Reading a file into a multidimensional array
  • Object and struct member access and address offset calculation
  • x64 applications using gdi+: what are the consequences on performance?
  • Hardware Accelerated Image Scaling in windows using C++
  • Content-Length header not returned from Pylons response
  • Magento Fatal error: Maximum execution error solution, on WAMP
  • Functions in global context
  • Repeat a vertical line on every page in Report Builder / SSRS
  • Sails.js/waterline: Executing waterline queries in toJSON function of a model?
  • Android screen density dpi vs ppi
  • Why is the size of this struct 32?
  • Bug in WPF DataGrid
  • Redux, normalised entities and lodash merge
  • Statically linking a C++ library to a C# process using CLI or any other way
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Do create extension work in single-user mode in postgres?
  • SVN: Merging two branches together
  • Hibernate gives error error as “Access to DialectResolutionInfo cannot be null when 'hibernate.
  • PHP: When would you need the self:: keyword?
  • log4net write single file for each call to log.info
  • Benchmarking RAM performance - UWP and C#
  • Acquiring multiple attributes from .xml file in c#
  • C# - Getting references of reference
  • -fvisibility=hidden not passed by compiler for Debug builds
  • How to CLICK on IE download dialog box i.e.(Open, Save, Save As…)
  • Can Visual Studio XAML designer handle font family names with spaces as a resource?
  • How can I remove ASP.NET Designer.cs files?
  • Are Kotlin's Float, Int etc optimised to built-in types in the JVM? [duplicate]
  • java string with new operator and a literal