Home > Blockchain >  DotNetBenchmark throws reference assembly error
DotNetBenchmark throws reference assembly error

Time:11-26

I want to test the performance of some methods using BenchmarkDotnet. Therefore, I downloaded the NuGet package added the usings and implemented it like this:

BenchmarkRunner.Run<SortingAlgorithmBenchmark>();

public class SortingAlgorithmBenchmark
{
    [Benchmark]
    public void BubbleSort()
    {
        SortingAlgorithms.BubbleSort(new[] {2,3,1});
    }
}

The BenchmarkRunner is in a console application which should show the output. Unfortunately the I keep getting this error: MSB3971: The reference assemblies for ".NETFramework,Version=v6.0" were not found. You might be using an older .NET SDK to target .NET 5.0 or higher

I don´t know where this error comes from since I never had a problem with the assembly references before and everything should be installed properly. At least I don´t know what could be wrong. Does anyone have an idea how to solve this problem. I run the program in VS 2022 and the TargetFramework is .Net 6.0

dotnet sdk folder

Microsoft.NET folder

CodePudding user response:

According to the comments.

The solution to solve this question is to change the target to .Net Framework 4.5 .

CodePudding user response:

It turned out that the problem was an unnecessary environment variable which pointed to the wrong sdk. After deleting the variable and restarting Visual Studio everything worked out fine.

  • Related