Wrong assembly binding redirects for Microsoft.Data.SqlClient.resources ; using in Netcore3.0 project
Hello BenchmarkDotNet Team,
We are exploring using this library to get relative benchmarks of integration tests. Both the calling project and the integration test project are .Net Core 3.0. We are using the latest .Net standard version of BenchmarkDotNet. While the benchmark begins to run, we notice the errors below.
// Wrong assembly binding redirects for Microsoft.Data.SqlClient.resources, Version=1.10.19324.4, Culture=en-US, PublicKeyToken=23ec7fc2d6eaa4a5. // Wrong assembly binding redirects for Microsoft.Data.SqlClient.resources, Version=1.10.19324.4, Culture=en, PublicKeyToken=23ec7fc2d6eaa4a5. // Wrong assembly binding redirects for Microsoft.Data.SqlClient.resources, Version=1.10.19324.4, Culture=en-US, PublicKeyToken=23ec7fc2d6eaa4a5. // Wrong assembly binding redirects for Microsoft.Data.SqlClient.resources, Version=1.10.19324.4, Culture=en, PublicKeyToken=23ec7fc2d6eaa4a5. // Wrong assembly binding redirects for System.Data.Common.resources, Version=4.2.2.0, Culture=en-US, PublicKeyToken=b03f5f7f11d50a3a. // Wrong assembly binding redirects for System.Data.Common.resources, Version=4.2.2.0, Culture=en, PublicKeyToken=b03f5f7f11d50a3a.
The integration test includes calls to databases and thus the need for these packages. We have confirmed the binaries between the calling project and the referenced project match.
Here is our benchmark class:
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Engines;
using BenchmarkDotNet.Environments;
using BenchmarkDotNet.Jobs;
using System;
using ABC.DS.DataAccess.Application.IntegrationTests;
namespace ABC.DS.DataAccess.Benchmark.XYZ
{
/// <summary>
/// Benchmarks the XYZServiceTests integration tests.
/// </summary>
[SimpleJob(RunStrategy.ColdStart, targetCount: 10)]
[CsvExporter]
//Using [SimpleJob(RuntimeMoniker.NetCoreApp30, targetCount: 10)] did not resolve the issue
public class XYZServiceTestsBenchmark
{
private XYZServiceTests XYZServiceTests { get; } = new XYZServiceTests();
/// <summary>
/// Left as a reference - using the following config did not resolve the issue
/// </summary>
private class Config : ManualConfig
{
public Config()
{
var job = Job.Default.With(CoreRuntime.Core30);
job.Run.RunStrategy = RunStrategy.ColdStart;
job.Run.IterationCount = 10;
job = job.WithNuGet("Microsoft.Data.SqlClient", "1.1.0").WithId("1.1.0");
job = job.WithNuGet("System.Data.Common", "4.3.0").WithId("4.3.0");
Add(job);
}
}
[IterationSetup]
public void IterationSetup()
{
XYZServiceTests.SetUp();
}
[IterationCleanup]
public void IterationCleanup()
{
XYZServiceTests.TearDown();
}
[Benchmark]
public void BenchmarkA()
{
XYZServiceTests.TestA()
}
[Benchmark]
public void BenchmarkB()
{
XYZServiceTests.TestB();
}
}
}
Your response is greatly appreciated and we look forward to integrating BenchmarkDotNet in our project!
Hello @JIoffe
The short answer is that you can ignore this warning.
The long answer: for some reason VS sometimes generates invalid assembly binding redirects for Full .NET Framework projects. It was causing a lot of trouble to our users in the past: #895, #667, #896, #942 . I decided to implement an ugly workaround that searches for .dll file manually and loads it when .NET Framework fails to do so.
Of course, this applies only to Full .NET Framework. When I was porting BenchmarkDotNet to .NET Standard 2.0 I've forgotten that we don't need to do this for .NET Core. As the end result you get this confusing warning.
I've sent a PR that fixes that: #1365 and this workaround will now be executed only for Full .NET Framework project