[c#] Could not resolve this reference. Could not locate the assembly

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...

This question is related to c# .net

The answer is


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.


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> 

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.


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


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.


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.


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.


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>

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.


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 

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.


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.