Wrong assembly is being referenced in solution
See original GitHub issueWrong assembly is being referenced in solution
When trying to reference 1.0.4. version of an assembly - 1.0.1 version of file is being used… Despite the fact, that project settings are pointing to the correct DLL. As the result - the solution is still compiled with 1.0.1 version.
General
Specs
OS:
- OS Name Microsoft Windows 10 Enterprise
- Version 10.0.16299 Build 16299
VS:
- Microsoft Visual Studio Professional 2017
- Version 15.9.7
- VisualStudio.15.Release/15.9.7+28307.423
- Microsoft .NET Framework
- Version 4.7.02556
dotnet --version
- 2.2.104
Prerequisites
Checkout the solution from my repo:
https://github.com/pavlexander/dotnetbugs/tree/master/Bugs/12032019_WrongAssemblyLoaded
Steps to reproduce
- Open the solution in VisualStudio
- Right click on project, “Add -> Reference”.
- Browse for file in directory: “…12032019_WrongAssemblyLoaded\WrongAssemblyLoaded\DebugTests.Common.NugetWithPdb.1.0.4\lib\netstandard2.0\DebugTests.Common.NugetWithPdb2.dll” Proceed with adding of a reference. Note that file from 1.0.4 is selected.
- Right click on project, click “Edit WrongAssemblyLoaded.csproj”
- Verify that correct assembly is specified:
<ItemGroup>
<Reference Include="DebugTests.Common.NugetWithPdb">
<HintPath>DebugTests.Common.NugetWithPdb.1.0.4\lib\netstandard2.0\DebugTests.Common.NugetWithPdb2.dll</HintPath>
</Reference>
</ItemGroup>
- Now, in VisualStudio, expand the tree of the project -> Dependencies -> Assemblies, find the assembly that you referenced and check the path.
Expected result:
Assembly from 1.0.4 folder is used
Actual result:
…\dotnetbugs\Bugs\12032019_WrongAssemblyLoaded\WrongAssemblyLoaded\DebugTests.Common.NugetWithPdb.1.0.1\lib\netstandard2.0\DebugTests.Common.NugetWithPdb.dll
And this is the issue. Assembly of version “1.0.1” is used in project, despite even the fact that in project settings “1.0.4” version is specified. If you try and build the solution now, in the output folder you will also see the “1.0.1” version. I don’t think this is related to Visual Studio in any way. Because, even if you try to use the dotnet build
command directly - it will also put the same wrong dll into an output directory.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (4 by maintainers)
@nguerrera: IT WORKS! 😃
Lucky if found this thread! Could just as well have taken me weeks, months or never to solve this…scary thought! Very frustrating the path you specify in the project file is not respected. Think this guy had the same problem, but as usual it’s a waste of time to report anything on developercommunity. https://developercommunity.visualstudio.com/t/assembly-reference/483348
Running VS 2022 (64-bit) - LTSC 17.0Version 17.0.15 / .NET SDK 6.0.402
Try adding this to .csproj:
This removes CandidateAssemblyFiles that will find assemblies in the None and Content items, which for sdk projects will include all files under the csproj by default.