1

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

  • Welcome to Stackoverflow. You may need to provide more information to allow us to reproduce the problem. I tested the sample code in the same environment, and the test is intact. Check this [link?](https://mixedpad.com/net6-framework-were-not-found/) Does it help you? – Jiale Xue - MSFT Nov 26 '21 at 06:51
  • Hi I added pictures of the dotnet sdk folder and Microsoft.NET folder. Maybe something´s wrong with them? – VR46_Italia Nov 26 '21 at 07:02
  • Have you tried the [fix in the link](https://mixedpad.com/net6-framework-were-not-found/)? You can edit and delete the relevant content and tags of `Benchmark`. It seems that it has nothing to do with these at present. – Jiale Xue - MSFT Nov 26 '21 at 07:09

1 Answers1

2

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.