Skip to content

chore: Fix VSTestAdapter throw exception on test discovery for project that targeting net462#2982

Merged
timcassell merged 1 commit intodotnet:masterfrom
filzrev:chore-fix-vstestadaper-error-on-net462
Jan 28, 2026
Merged

chore: Fix VSTestAdapter throw exception on test discovery for project that targeting net462#2982
timcassell merged 1 commit intodotnet:masterfrom
filzrev:chore-fix-vstestadaper-error-on-net462

Conversation

@filzrev
Copy link
Contributor

@filzrev filzrev commented Jan 27, 2026

This PR intended to fix following VSTestAdapter issue on net462.

How to reproduce error on VS

  1. Build BenchmarkDotNet.Samples project with Release configuration on Visual Studio
  2. FileLoadExceptionexception are recorded on Test output pane on test discovery phase.
  3. Test Explorer don't show benchmarks for net462

As far as I've remember.
Test Explorer show benchmarks for net462 previously.
So, it's expected to be caused by dependent package version conflict between TestAdaper/BenchmarkDotNet for following packages.

  • System.Collections.Immutable
  • System.Memory

It seems not resolved by adding PackageReference to TestAdapter project.
I've added temporary that manually resolve following assemblies by AppDomain.CurrentDomain.AssemblyResolve.
(That is same temporary workaround code that is used to load BenchmarkDotNet.dll for net462)

{
return Assembly.LoadFrom(path);
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Above code blocks can be simplified without code copy&paste.

But this workaround code is expected to be removed in future when TestAdapter is migrated to use MTPv2 instead of VSTest. So these code are expected to be leave as is.

@timcassell timcassell merged commit dc6faf6 into dotnet:master Jan 28, 2026
11 checks passed
@timcassell timcassell added this to the v0.16.0 milestone Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments