Skip to content

[dotnet-sdk-11.0.100-preview.4.26214.103] GlobalToolsNETCore21Part02 execute "dotnet vstest" failed with error: System.TypeLoadException : Could not load type 'Microsoft.Extensions.Logging.Internal.FormattedLogValues'... #126995

Closed

Description

@WeiweiCaiAcpt

Description

When running "dotnet vstest DockerWatch.Test.dll" on latest build dotnet-sdk-11.0.100-preview.4.26214.103, there are three cases failed with error: System.TypeLoadException : Could not load type 'Microsoft.Extensions.Logging.Internal.FormattedLogValues' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=11.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.

Reproduction Steps

Environment Configuration:

  1. Copy GlobalToolsNETCore21Part02Test56 from \appcompatsrv\BugRepro_Share\2940187 to local machine.
  2. Install dotnet-sdk-11.0.100-preview.4.26214.103.
  3. Modify DockerWatch.Test.runtimeconfig.json to enable the app to run on dotnet-sdk-11.0.100-preview.4.26214.103.
    "framework": {
    "name": "Microsoft.NETCore.App",
    "version": "11.0.0-preview.4.26214.103"
    }

Repro Steps:

  1. Open cmd in GlobalToolsNETCore21Part02Test56.
  2. Execute command: dotnet vstest DockerWatch.Test.dll.

Expected behavior

Passed! - Failed: 0, Passed: 18, Skipped: 0, Total: 18, Duration: 3 s - DockerWatch.Test.dll

Actual behavior

Error Message:
System.TypeLoadException : Could not load type 'Microsoft.Extensions.Logging.Internal.FormattedLogValues' from assembly 'Microsoft.Extensions.Logging.Abstractions, Version=11.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
Stack Trace:
at DockerWatch.Test.LoggerAdapterTest.LogInformation_ShouldLogAnInformationMessage() in C:\Users\v-joyzhu\Desktop\unit test\docker-watch-master\docker-watch-master\test\DockerWatch.Test\LoggerAdapterTest.cs:line 17
at System.Reflection.MethodBaseInvoker.InterpretedInvoke_Method(Object obj, IntPtr* args)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)

Failed! - Failed: 3, Passed: 15, Skipped: 0, Total: 18, Duration: 3 s - DockerWatch.Test.dll

Regression?

Yes

Verify Scenarios:
1). Windows 11 25H2 AMD64 + dotnet-sdk-11.0.100-preview.3.26207.106: Pass
2). Windows 11 25H2 AMD64 + dotnet-sdk-11.0.100-preview.4.26210.111: Fail
3). Windows 11 25H2 AMD64 + dotnet-sdk-11.0.100-preview.4.26214.103: Fail

Known Workarounds

No response

Configuration

Application Name: GlobalToolsNETCore21Part02
OS: Windows 11 25H2
CPU: X64
.NET Build Number: dotnet-sdk-11.0.100-preview.4.26214.103

dotnet --info
.NET SDK:
Version: 11.0.100-preview.4.26214.103
Commit: b94d039caa
Workload version: 11.0.100-manifests.d6ec7560
MSBuild version: 18.7.0-preview-26214-103+b94d039ca

Runtime Environment:
OS Name: Windows
OS Version: 10.0.26200
OS Platform: Windows
RID: win-x64
Base Path: C:\Program Files\dotnet\sdk\11.0.100-preview.4.26214.103\

Host:
Version: 11.0.0-preview.4.26214.103
Architecture: x64
Commit: b94d039caa

.NET SDKs installed:
11.0.100-preview.4.26214.103 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 11.0.0-preview.4.26214.103 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 11.0.0-preview.4.26214.103 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 11.0.0-preview.4.26214.103 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other information

@dotnet-actwx-bot @dotnet/compat

Activity

  1. added
    untriaged
    on Apr 16, 2026
  2. dotnet-policy-service commented on Apr 16, 2026

    @dotnet-policy-service
    Contributor

    Tagging subscribers to this area: @dotnet/area-extensions-logging
    See info in area-owners.md if you want to be subscribed.

  3. tarekgh commented on Apr 16, 2026

    @tarekgh
    Member
  4. tarekgh commented on Apr 16, 2026

    @tarekgh
    Member

    What’s happening is that the tests bring in Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0, and DockerWatch.Test references that assembly. After moving Microsoft.Extensions.Logging.Abstractions assemly (and its dependencies) to NetCoreApp in .NET 11, the tests began loading the version that ships with the .NET 11 SDK instead.

    The issue is that in version 2.1.1.0, certain types, such as NullScope are defined under the Microsoft.Extensions.Logging.Abstractions.Internal namespace. In newer versions, these types were moved to Microsoft.Extensions.Logging. Similarly, FormattedLogValues was previously under Microsoft.Extensions.Logging.Internal but now resides in Microsoft.Extensions.Logging.

    DockerWatch.Test directly references these older internal types, for example:

    [Fact]
    public void LogInformation_ShouldLogAnErrorMessage()
    {
        Mock<ILogger<MockService>> logger = new Mock<ILogger<MockService>>();
        LoggerAdapter<MockService> adapter = new LoggerAdapter<MockService>(logger.Object);
        adapter.LogError("error");
    
        logger.Verify((ILogger<MockService> m) =>
            m.Log(
                LogLevel.Error,
                It.IsAny<EventId>(),
                It.Is((FormattedLogValues v) => v.ToString().Contains("error")), // <---------- FormattedLogValues referenced here
                It.IsAny<Exception>(),
                It.IsAny<Func<object, Exception, string>>()));
    }

    This results in a type's load exception, since those internal namespaces no longer exist in the newer assemblies.

    @ericstj might have guidance here, as I’m unsure whether DockerWatch.Test should be rebuilt against the updated .NET 11 dependencies, or if there’s a way to force loading the older Microsoft.Extensions.Logging.Abstractions, Version=2.1.1.0 instead of the version included with .NET 11.

  5. removed
    untriaged
    on Apr 20, 2026
  6. self-assigned this
    on Apr 20, 2026
  7. ericstj commented on Apr 20, 2026

    @ericstj
    Member

    I was aware of these breaks in Extensions from a few years back when we tried to improve the compatibility from 2.x era extensions to latest. At the time we didn't add back these pub-ternals because we didn't see a lot of usage in other packages except our own packages - which folks could update. Now that we force this in .NET 11 without necessarily a developer around to rebuild (roll forward) we can look at a better fix. I have a change in progress that will add back the removed types. https://github.com/dotnet/runtime/tree/copilot%2Fadd-null-scope-type-back

  8. WeiweiCaiAcpt commented on Apr 28, 2026

    @WeiweiCaiAcpt
    Author

    @tarekgh @ericstj When running with dotnet-sdk-11.0.100-preview.4.26224.122, the System.TypeLoadException is no longer reproducible; however, a new Moq.MockException has surfaced. We’ve filed a new bug for this issue. Could you please help take a look?

  9. locked and limited conversation to collaborators on May 28, 2026
  10. added this to the 11.0.0 milestone on Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions