I am aware that there is already a question here asking about the exact same error message, but unfortunately the accepted answer doesn't work for me.
I was able to build my current solution successfully earlier this morning, but the build suddenly started failing ~15 minutes ago, with the following error message:
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1820,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "MyAssembly.dll". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Unfortunately for me, this DLL is required by my code. Because it cannot be located, my solution won't compile.
I have tried cleaning and then building my solution again, but that was useless.
I noticed that there was a yellow icon next to this reference, so I removed the reference and then added it again from the exact same location specified inside the <HintPath>
tag in my .csproj
file. (The location was the \bin\Debug
folder.) The yellow icon then disappeared.
However, immediately after I clicked on "Build solution" (in Debug
mode), the yellow icon appeared again, and once more I saw the same MSBuild error message, informing me that the DLL could not be located.
How can I resolve this issue?
Add a project reference to the MyAssembly
project, not a reference to the compiled output. Right click on the References node of the project which needs MyAssembly.dll
, go to "Add Reference", then choose "Solution":
Say you have two projects (X and Y) with Y depending on X. Visual Studio will build X first, then Y.
You can add a reference to X in Y in one of two ways:
\bin\Debug
folderIf the reference is to the project in the solution, then Visual Studio will know which order to compile your projects (X, then Y in our example).
If the reference is to the output in \bin\Debug
, then Visual Studio won't know which order to compile the assemblies, and could try to compile Y before X, not find the file in \bin\Debug
, and not compile.
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