11

Visual Studio Version: 2019 Summary: I have two framework projects in same folder, 4.7 framework project has local Nuget Package reference and 4.5 framework project has local Assembly reference. The reported issue occurs when run 4.5 project after run the 4.7 projects

Issue: Severity Code Description Project File Line Suppression State Error Your project does not reference ".NETFramework,Version=v4.5" framework. Add a reference to ".NETFramework,Version=v4.5" in the "TargetFrameworks" property of your project file and then re-run NuGet restore.

4.7 Project

  <ItemGroup>
   <PackageReference Include="Microsoft.Xaml.Behaviors.Wpf" Version="1.1.19" />
</ItemGroup>

4.5 Project

<Reference Include="Microsoft.Xaml.Behaviors.Wpf" xmlns="">
  <HintPath>..\resources\Assembilies\Microsoft.Xaml.Behaviors.dll</HintPath>
</Reference>

Steps to Reproduce:

  1. Run 4.7 project with nuget reference

  2. run 4.5 project with assembly reference

  3. will reproduce the reported issue

How to solve this issue

6
  • Seems legit, .net framework only supports backward version compatibility. On the first run Microsoft.Xaml.Behaviors.dll is generated in 4.7. It is not overriden on the second run so it crashes. Commented Sep 1, 2020 at 13:00
  • why can't you upgrade the 2nd project in 4.7 ? Commented Sep 1, 2020 at 13:02
  • @B.Lec Cleaning bin and Obj fix the issue but it needs to be calls before the build Starts Commented Sep 1, 2020 at 13:03
  • @B.Lec No i need those projects in both framework Commented Sep 1, 2020 at 13:04
  • Why are they in the same folder ? Commented Sep 1, 2020 at 13:16

1 Answer 1

27

If anyone is ever stuck on a legacy project, the solution in the end was to delete the contents of bin and obj folders, and the .vs directory for the solution.

Sign up to request clarification or add additional context in comments.

1 Comment

this helped for me: I removed .vs, bin, obj from the source folders for every assembly mentioned in the errors (not entire solution).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.