Why would all of my references have yellow exclamation points on them in my .NET class library?

31,777

Solution 1

Using the Solution Explorer, right mouse click and select Unload Project and then select Edit (name of your csproj file) to be able to edit the .csproj file directly in VS.

Under one of the <ItemGroup> nodes you will find subnodes tagged Reference. Ensure that the HintPath node value points to a valid path. Also double check the nodes SpecificVersion and Private for valid values.

Hopefully evaluating these values will help you resolve your problem.

Solution 2

Just to add to this. I recently had an issue where I was adding references that had the TargetFramework set to .NET 4.0 to a Visual Studio 2008 project. All you get is a yellow exclamation mark and explanation.

Once I realised I picked the wrong release binaries it seemed obvious!

Solution 3

Check weather the project .NET framework is equal or greater than reference .Net framework

Solution 4

my problem was difference in target .NET framework versions set on the projects. the first was set to .NET 4.0 and the second was .NET 4.5 changing it solved my problem

Solution 5

I got the same issue with a project opened in Visual Studio 2015 recently.

The error came out when I've relocated a few times the physical location of the solutions default package repositories and deliberately changed the value of the repositoryPath in the NuGet.Config

In my case, I needed to remove an element whose path pointed to by the condition attribute is invalid that is inside the Target section of the csproj file.

<Error Condition="!Exists('..\..\..\..\..\Packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets')" 
       Text="$([System.String]::Format('$(ErrorText)', '..\..\..\..\..\Packages\Microsoft.Bcl.Build.1.0.21\build\Microsoft.Bcl.Build.targets'))" />

Also, this error is reproduced when the usual Package folder is removed or relocated elsewhere. One should then update this value along with the ItemGroups.

Share:
31,777

Related videos on Youtube

Luc
Author by

Luc

I'm a senior full stack .NET developer with 20+ years of experience. My passion for coding started in the late 1990's with a college course in assembler language. I then turned my focus to coding personal computers as a self-taught Visual Basic guru. I was an early (beta) user of C# with my first job (a .NET component company) and have been building solutions with C# ever since. Over the years I have developed all kinds of applications. My current job allows me to develop solutions in ASP.NET Core with .NET 5. I'm a huge fan of Javascript and (yes, even) Typescript. I'm very excited about Blazor! A few years of my life were dedicated to learning all things UNIX. My main focus was on Ruby on Rails with MySQL back-end. I hosted a few projects on a Linode box (that I still have). This endeavor was for me to step outside my comfort zone and grow as a developer. It was a lot of fun to learn a different stack. Ultimately, I truly love the Microsoft stack and developer tools.

Updated on July 09, 2022

Comments

  • Luc
    Luc almost 2 years

    I've been developing a class library for quite sometime and all of the sudden, sometime last week, I opened my project and all of my references have yellow exclamation points on them now (System.dll, System.Drawing.dll, etc..). I've tried removing the references and re-adding them to fix any broken reference paths, but they continue to show yellow exclamation points on them.

    Nothing had changed since the last time I'd opened the project. The only thing that was different from the last time I'd opened the project was that this time I opened it from directly inside of .NET from another project. For example, I was working on a .NET 3.5 web project, then clicked File -> Open Recent Files -> My Other Solution. This closed my current current 3.5 web solution and opened the 2.0 class library solution and the problem appeared for the first time. I'm not sure how (or why) this would cause a problem, but I'm leaning toward the fact that Visual Studio got confused or something and now my assemblies are all invalid on this 2.0 class library project. (?)

    What would cause this to happen and how can I fix it? I've looked around the web, but I only see that people have suggested to remove the references and re-add them; which I've done, to no avail.

    I'm considering starting a new project and copying over all of my source files one by one, but would really like to avoid all this if possible.

    Thanks in advance!

    • Admin
      Admin over 13 years
      Is one project using .Net 2.0 while another project in the same solution uses .Net 3.5? And one project references the other?
  • Luc
    Luc over 13 years
    Thanks for your tip. I did what you said and everything looks correct in the <ItemGroup>. I simply changed all of my relative references (ie. '..\..\..\') to absolute references (ie. 'c:\') and the exclamation points magically went away. :) Thanks again!
  • pfeds
    pfeds about 10 years
    Ha, that was exactly the issue I was having - Thanks.
  • Contango
    Contango almost 9 years
    This fixed the issue for me - project was configured for .NET 4.5, and I should have configured the project for .NET 4.5.1.
  • pashute
    pashute almost 9 years
    as @reza_baiat said (I missed that one)
  • Matt Borja
    Matt Borja over 8 years
    Had the same problem here; .NET 4.5 project referencing a .NET 4.5.1 project wouldn't compile until I did this. Thanks!
  • shivesh suman
    shivesh suman over 8 years
    A symptom to this is that types are recognized by IntelliSence and you can write code in Visual Studio using the types in referenced library however the code would not compile and you see a yellow exclamation mark for that reference assembly. Unfortunately there is no tool tip to tell us what is wrong.
  • FloverOwe
    FloverOwe over 2 years
    Luc, wouldn't such hard-wiring of paths make cross-deployments difficult? Maybe the default isn't set up right. Where does it get the default "current" app path and how can we verify and adjust it? Thanks