Visitar URL original
x86 testhost fails to load runtime (hostfxr 0x800700C1) in 18.9.0-preview via vstest.console.exe — regression of #15235 / dotnet/sdk#49436 · Issue #16151 · microsoft/vstest · GitHub
Skip to content

x86 testhost fails to load runtime (hostfxr 0x800700C1) in 18.9.0-preview via vstest.console.exe — regression of #15235 / dotnet/sdk#49436 #16151

Closed

Description

Summary

An x86 test project still fails to launch its testhost with hostfxr error 0x800700C1 (ERROR_BAD_EXE_FORMAT) when using Microsoft.TestPlatform.TestHost / Microsoft.NET.Test.Sdk 18.9.0-preview-26319-02, run via vstest.console.exe.

The x86 testhost.x86.exe resolves the runtime from a 64-bit .NET install (the one DOTNET_ROOT points at) and then tries to load the x64 hostfxr.dll into the x86 process, which fails with 0x800700C1 (bad image format / architecture mismatch).

This looks like the same regression as the now-closed #15235, which was closed as a duplicate of dotnet/sdk#49436. That SDK issue is marked completed (closed 2025-10-27), but we are still hitting it with the 18.9.0-preview-26319-02 package and via the vstest.console.exe path (not only dotnet test --arch x86). So either the fix has not flowed into this preview of the TestPlatform packages, or the console-host x86 runtime resolution path is not covered by the fix.

Versions

  • Microsoft.TestPlatform.TestHost = 18.9.0-preview-26319-02
  • Microsoft.NET.Test.Sdk = 18.9.0-preview-26319-02
  • Last known-good for the same project: Microsoft.TestPlatform.TestHost 17.6.1 / Microsoft.NET.Test.Sdk 17.2.0
  • Runner: vstest.console.exe
  • OS: Windows x64; DOTNET_ROOT points to an x64 .NET install (no separate x86 runtime on DOTNET_ROOT(x86))

Affected project shape

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <PlatformTarget>x86</PlatformTarget>
    <IsTestProject>true</IsTestProject>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.NET.Test.Sdk" />
    <PackageReference Include="xunit" />
  </ItemGroup>
</Project>

The test assembly is x86 (PlatformTarget x86) on a net8.0 TFM, executed through vstest.console.exe.

Error

Testhost process for source(s) '<path>\Tests.dll' exited with error: Failed to load the dll from [<dotnet-x64-root>\host\fxr\10.0.8\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from <dotnet-x64-root>\host\fxr\10.0.8\hostfxr.dll failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=798306
Failed to resolve hostfxr.dll [<dotnet-x64-root>\host\fxr\10.0.8\hostfxr.dll]. Error code: 0x80008082
. Please check the diagnostic logs for more information.
Test Run Aborted.

Note the x86 testhost rolls forward to a .NET 10 runtime and resolves the x64 hostfxr.dll (the only one under DOTNET_ROOT), then fails to load it into the x86 process.

Expected

The x86 testhost should resolve and load an x86 runtime/hostfxr.dll (e.g. via DOTNET_ROOT(x86), registry, or default x86 install location), or fail with a clear, actionable diagnostic — not attempt to load the x64 hostfxr.dll into an x86 process.

Notes / ask

Related

Activity

  1. added a commit that references this issue on Jun 23, 2026
  2. nohwnd commented on Jun 23, 2026

    @nohwnd
    Member

    PR #16156 has been opened by @azat-msft to address this regression.

    Root cause (from the PR): When vstest.console.exe is invoked directly (not via dotnet test), the SDK never sets VSTEST_DOTNET_ROOT_PATH / VSTEST_DOTNET_ROOT_ARCHITECTURE, so the architecture-specific DOTNET_ROOT_<ARCH> is never computed. The x86 testhost then inherits the architecture-less DOTNET_ROOT from the environment, which on a standard x64-only machine points at an x64 install. The x86 apphost applies that DOTNET_ROOT regardless of its own architecture and loads the x64 hostfxr.dll — causing 0x800700C1.

    Fix: When an architecture-specific apphost is launched and the SDK path hint is absent, vstest now promotes the architecture-less DOTNET_ROOT to the matching DOTNET_ROOT_<ARCH> (determined by reading the dotnet muxer's PE header) and clears the architecture-less variable so it doesn't contaminate a different-architecture apphost.

    🔍 Triaged by Issue Repro Triage & Auto-Fix 🔍

    🔍 Triaged by Issue Repro Triage & Auto-Fix 🔍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions