This is a weird one.
I have Visual Studio 2013 installed. If I create a new project, Visual Studio immediately complains that it cannot find any of the references:
The project does however compile and run correctly, even though there are warnings in the error list:
If I look at the properties of any of these references, their paths are empty. If I load an existing project, Visual Studio can find its references and doesn't complain, even though it is targeting the same version of the .Net framework as the broken project (I've even had them both in the same solution with the same behaviour).
How can I fix this, and what could have caused it? Any suggestions welcome, as it is baffling me.
To fix a broken project reference by correcting the reference path. In Solution Explorer, right-click your project node, and then select Properties. The Project Designer appears. If you're using Visual Basic, select the References page, and then click the Reference Paths button.
Press Shift + F12 to find all references.
You can use the Find All References command to find where particular code elements are referenced throughout your codebase. The Find All References command is available on the context (right-click) menu of the element you want to find references to. Or, if you are a keyboard user, press Shift + F12.
I had a problem with an existing project, and by creating a new one and comparing the csproj files I had to add missing import lines like those: one at the beginning of the project element and one at the end.
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
...
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
This happens to me from time to time and I always suspect VS corruption, but it always turns out to be user error. It typically happens when I add a new project to a solution and try to reference earlier projects in the newly added project. In this case and in general, you can only add a reference if it targets the same or earlier .NET Framework version. In my case, inconsistent target framework versions caused the project to not recognize references and not allow compilation. Double checking consistency or proper target framework versions solved this problem for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With