The primary reference could not be resolved because it was built against a higher version of the .NET framework than the currently targeted framework

前端 未结 2 517
感情败类
感情败类 2021-02-12 13:11

I am trying to build a project that references a 3rd party SlingshotClient.dll. The project builds fine on other developers workstations. However, I am getting the error below.

2条回答
  •  一整个雨季
    2021-02-12 13:43

    Apparently if you have only .NET Frameworks 4.0 installed, you can add as a reference a .NET assembly that targets 4.5 to a project that targets .NET 4.0. This will compile and run with no errors.

    As soon as you install .NET Frameworks 4.5, compile will fail. The solution is to target your project for .NET Framework 4.5 or get a version of the referenced assembly that targets .NET 4.0.

    .NET 4.5 is a drop in replacement for 4.0. 4.0 doesn't know anything about 4.5, and I assume it is just looking at the first digit of the version number which for 4.0 or 4.5 is the same, so it is allowed to compile. As soon as you install 4.5, your 4.0 projects are compiled using the 4.5 Frameworks and it now knows about 4.5 and complains.

提交回复
热议问题