Could not resolve this reference. Could not locate the assembly

C#.Net

C# Problem Overview


Everytime I build my solution, I get this error message:

> Warning > > 3 > > Could not resolve this reference. Could not locate the > assembly "StandardClassLibrary, Version=1.0.0.0, Culture=neutral, > processorArchitecture=MSIL". Check to make sure the assembly exists on > disk. If this reference is required by your code, you may get > compilation errors. > > StandardClassLibrary

So my application has a number of projects of which StandardClassLibrary is one. The above message is a warning and as far as I can tell it does NOT have an impact on my solution.

But I would rather it not be there, just in case...

C# Solutions


Solution 1 - C#

You most likely get this message when the project points to an old location of the assembly where it no longer exists. Since you were able to build it once, the assembly has already been copied into your bin\Debug / bin\Release folders so your project can still find a copy.

If you open the references node of the project in your solution explorer, there should be a yellow icon next to the reference. Remove the reference and add it again from the correct location.

If you want to know the location it was referenced from, you'd have to open the .csproj file in a text editor and look for the HintPath for that assembly - the IDE for some reason does not show this information.

Solution 2 - C#

If anyone face this issue with some nuget packages, you can fix that by reinstalling the packages using the Package Manager Console:

Update-Package -reinstall 

Solution 3 - C#

If you have built an image with Docker, and you're getting these strange messages:

> warning MSB3245: Could not resolve this reference. Could not locate > the assembly "Microsoft.Extensions.Configuration.Abstractions". Check > to make sure the assembly exists on disk. If this reference is > required by your code, you may get compilation errors. > [/src/Utilities/Utilities.csproj]

Open the affected projectUtilities/Utilities.csproj, (You shall look for your project). You may need to choose Unload Project from the menu first. Right click on the .csproj file and edit it.

Now, delete all the <HintPath> tags

Save, and try again.

enter image description here

enter image description here

Solution 4 - C#

Check if your project files are read-only. Remove the read-only property by right clicking on the project folder and select properties. In the properties screen remove the read-only checkbox. I came across the same problem, and this solved it for me.

Solution 5 - C#

If the project is check out to different PC through team foundation server with different location of same library file, there will be no yellow icon mark in Reference but when change to Release build and build the project, it will give an error. Just like what @C.Evenhuis said, it will use back old one in previous build (eg: Debug build) so I didn't notice the mistake.

Now I know it is a bad habit to put library files in different location on different PC.

Just need to delete the reference and re-add the same reference from correct location.

Solution 6 - C#

I had the same warning in VS 2017. As it turned out in my case I had added a unit test project and needed to set a dependency for the unit test on the DLL it was testing.

Solution 7 - C#

Maybe it will help someone, but sometimes Name tag might be missing for a reference and it leads that assembly cannot be found when building with MSBuild. Make sure that Name tag is available for particular reference csproj file, for example,

    <ProjectReference Include="..\MyDependency1.csproj">
      <Project>{9A2D95B3-63B0-4D53-91F1-5EFB99B22FE8}</Project>
      <Name>MyDependency1</Name>
    </ProjectReference>

Solution 8 - C#

in 2020, this behavior still present with VS2019. (even if I clean projects from the solution explorer in VS2019, this not solves the problem)

The solution that worked for me was to open the folder of the project, and manually remove the \bin and \obj directories.

Solution 9 - C#

I had this issue after VS mac updation. iOS sdk was updated. I was referring the ios dll in project folder. The version number in the hintpath was changed.

Earlier:

<Reference Include="Xamarin.iOS">   
     <HintPath>..\..\..\..\..\..\..\..\Library\Frameworks\Xamarin.iOS.framework\Versions\13.18.2.1\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.iOS">
      <HintPath>..\..\..\..\..\..\..\Library\Frameworks\Xamarin.iOS.framework\Versions\13.18.1.31\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.iOS">          <HintPath>..\..\..\..\..\..\..\Library\Frameworks\Xamarin.iOS.framework\Versions\13.18.3.2\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
    </Reference>

I referred to the numbers in the previous commit and changed only the numbers in project folder, did nothing in android,ios folders. Worked for me!!!

Now:

<Reference Include="Xamarin.iOS">                                                            
 <HintPath>..\..\..\..\..\..\..\..\Library\Frameworks\Xamarin.iOS.framework\Versions\13.20.2.2\lib\mono\Xamarin.iOS\Xamarin.iOS.dll</HintPath>
        </Reference> 

Solution 10 - C#

In my case I had the following warnings:

> Could not resolve this reference. Could not locate the assembly "x". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.

> No way to resolve conflict between "x, Version=1.0.0.248, Culture=neutral, PublicKeyToken=null" and "x". Choosing "x, Version=1.0.0.248

The path to the dll was correct in my .csproj file but I had it referenced twice and the second reference was with another version. Once I deleted the unnecessary reference, the warning disappeared.

Solution 11 - C#

This confused me for a while until I worked out that the dependencies of the various projects in the solution had been messed up. Get that straight and naturally your assembly appears in the right place.

Solution 12 - C#

in my case, it happened because of .net framework version miss match with MySQL connector library. when I updated my .NET version, every thing worked smooth. http://net-informations.com/q/faq/mysql.html#:~:text=Add%20Reference,Library%20in%20your%20C%23%20project.

Solution 13 - C#

I had faced similar linker issues while adding a NuGet package into the iOS project (in Xamarin forms project). We had earlier provided the additional mtouch argument in the build configurations like this -dlsym:false -cxx -v -v -v -v -gcc_flags

After removing -dlsym:false from the configuration, the issues got resolved for me.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionarame3333View Question on Stackoverflow
Solution 1 - C#C.EvenhuisView Answer on Stackoverflow
Solution 2 - C#Martin BrandlView Answer on Stackoverflow
Solution 3 - C#Jose AView Answer on Stackoverflow
Solution 4 - C#user1682406View Answer on Stackoverflow
Solution 5 - C#scsfdevView Answer on Stackoverflow
Solution 6 - C#BHoltzmanView Answer on Stackoverflow
Solution 7 - C#JanisView Answer on Stackoverflow
Solution 8 - C#glihmView Answer on Stackoverflow
Solution 9 - C#Vipin KrishnaView Answer on Stackoverflow
Solution 10 - C#G StoykovView Answer on Stackoverflow
Solution 11 - C#Alex StricklandView Answer on Stackoverflow
Solution 12 - C#faizan aslamView Answer on Stackoverflow
Solution 13 - C#Prasanth RajView Answer on Stackoverflow