I know that there are many threads on this but I tried all possible solutions without any success.
I have a solution with multiple projects. Project A
has a reference to project B
. In my A.csproj
:
<ProjectReference Include="..BB.csproj">
<Project>{795b8266-e62c-4d04-b8eb-cfrf5a31f55x}</Project>
<Name>B</Name>
</ProjectReference>
I recently upgraded both projects Target framework from .Net Framework 4.6.1
to .Net Framework 4.8
.
After the upgrade, when I build project B
in VS it builds succesfully, but when I build project A
I get lots of errors of type code CS0246 The type or namespace name 'B' could not be found (are you missing a using directive or an assembly reference?)
.
The strange thing is that when I build the solution from the VS developer command prompt using MSBuild solution.sln
I get no errors, furthermore, if I change the reference from “ProjectReference” to a regular reference to the dll (browsing it), that error disappear.
<Reference Include="B, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..BbinReleaseB.dll</HintPath>
</Reference>
I want to be able to build the solution straight from the UI and not from the CMD, and I don’t want to make changes to the references as I have lots more references with same errors and I’m not quite sure if that’s a good idea to change projectreference to browsed reference.
What I tried to do:
- Made sure that there’s no .NET Target Framework mismatch, both projects
A
andB
and others uses .NET 4.8 - Ran
Update-Package –reinstall
in Nuget Package Manager CMD - Removed the reference and added it back
- Cleaned solution and Build again
- Unloaded both projects and reloaded them
- Restarted VS in admin mode
- Delete the project and reclone it
- Retarget solution to different Windows SDK versions
I’m building in Release, Mixed Platforms mode