Skip to content

Deployment item doesn't work well when app domain is disabled #6738

@Youssef1313

Description

@Youssef1313

This is a bug dating back to the oldest stable MSTest version on nuget.org. The two features never worked correctly together.

TestProject44.zip

Run with dotnet test -- RunConfiguration.DisableAppDomain=true:

  • All versions: The test assembly is loaded twice in the same app domain. Once from bin and once from deployment directory

    Image
  • Up to 3.10.5: The test fails with InvalidCastException:

        Example (10s 862ms): Error Message: Test method TestProject44.Test1.Example threw exception:
        System.InvalidCastException: [A]ExampleDataType cannot be cast to [B]ExampleDataType. Type A originates from 'TestProject44, Version=1.0.0.0, Culture=neutral, Pub
        licKeyToken=null' in the context 'LoadFrom' at location 'C:\Users\ygerges\source\repos\TestProject44\TestProject44\TestResults\Deploy_ygerges 2025-10-14 11_24_27\
        Out\TestProject44.dll'. Type B originates from 'TestProject44, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\Use
        rs\ygerges\source\repos\TestProject44\TestProject44\bin\Debug\net48\TestProject44.dll'.
        Stack Trace:
            at TestProject44.Test1.ExampleDataTypeTypeConverter.ConvertTo(ITypeDescriptorContext context, CultureInfo culture, Object value, Type destinationType) in C:\U
        sers\ygerges\source\repos\TestProject44\TestProject44\Test1.cs:line 33
           at TestProject44.Test1.Example() in C:\Users\ygerges\source\repos\TestProject44\TestProject44\Test1.cs:line 17
    
  • 3.11.0 and 4.0.0: the test passes, even if the assembly is still loaded twice. That might get broken as it was before again when Fix deployment regression #6718 is merged.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: MSTestIssues with MSTest that are not specific to more refined area (e.g. analyzers or assertions)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions