Skip to content

Invalid .NET 10 MissingMethodException with specific SDK versions #15029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
Evangelink opened this issue Mar 11, 2025 · 14 comments
Open

Invalid .NET 10 MissingMethodException with specific SDK versions #15029

Evangelink opened this issue Mar 11, 2025 · 14 comments

Comments

@Evangelink
Copy link
Member

Issue from dotnet/runtime#113302. We sadly cannot transfer issues across orgs.

@ericstj
Copy link
Member

ericstj commented Mar 11, 2025

The gist of the problem is that if a test relies on a NETStandard2.0 library that exposes types that were later inboxed in .NETFramework, that test will face type unification problems when running on mono.

The root cause is that the TestHostNetFramework contains one jumble of assemblies shared for multiple versions of .NET framework. Contrast that to what's actually provided to projects targeting these frameworks by Microsoft.NET.Build.Extensions where each framework gets the appropriate assemblies to unify types correctly. Notice how there exists both a C:\Program Files\dotnet\sdk\9.0.200\Microsoft\Microsoft.NET.Build.Extensions\net461\lib\System.ValueTuple.dll and C:\Program Files\dotnet\sdk\9.0.200\Microsoft\Microsoft.NET.Build.Extensions\net47\lib\System.ValueTuple.dll -- the latter must be used on net47 to ensure that the types unify with those in MSCorlib.

I can imagine a couple possible fixes for this problem.

  1. Stop shipping these assemblies entirely in the TestHostNetFramework and let the test bring them if it needs them.
  2. Segment the assemblies into subfolders so that multiple copies coexist, and specify them per-framework via the testhost.*.exe.config + probingPaths.

@Evangelink
Copy link
Member Author

Interesting, @Youssef1313 I would hope that MTP is not failing in that case then. Could we test that?

@Youssef1313
Copy link
Member

Youssef1313 commented Mar 11, 2025

I confirm that MTP works fine and it's VSTest-specific. @visschersm Thanks for providing a very minimal repro, accompanied with GitHub workflow that repro's the issue on GitHub Action. As the issue seems VSTest-specific, would it be an option for you to migrate over from VSTest to the newer Microsoft.Testing.Platform?

The migration process in many cases is:

  1. Add the following to your Directory.Build.props

    <PropertyGroup>
        <EnableMSTestRunner>true</EnableMSTestRunner>
        <TestingPlatformDotnetTestSupport>true</TestingPlatformDotnetTestSupport>
    
         <!-- Optional, you will find more info in docs -->
        <TestingPlatformCaptureOutput>false</TestingPlatformCaptureOutput>
    </PropertyGroup>
  2. Add <OutputType>Exe</OutputType> to your test projects

  3. Update dotnet test invocations to account for the new way of doing it.

Meanwhile, I'll move to vstest repo and will let @nohwnd advise if this can be fixed.

@Youssef1313 Youssef1313 transferred this issue from microsoft/testfx Mar 11, 2025
@visschersm
Copy link

First off all: Thank you for the response amazed by the level of detail! Learning a lot!

The issue for me was in a hobby project so luckily not a very big issue. Nevertheless finding it very interesting and hopefully it helps improving dotnet even more :)

@Youssef1313
I have added MTP in which the test passes as expected. Is MTP the advised way to run tests these days?

Do I understand the underlying issue correctly by stating that MTP does not use dll versions itself but just uses the versions brought by the code under test?

@ericstj
For libraries is it advised to build all the specific framework versions over using a shared .netstandard version? I am using it for some coditional compilation but I guess I could use the VERSION_OR_GREATOR as a replacement in those cases.

@nohwnd
Copy link
Member

nohwnd commented Mar 12, 2025

@visschersm thanks for the repro project, can you please update you microsoft.net.test.sdk to 17.14 preview from nuget?

https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.14.0-preview-25107-01

There we upgraded the versions and started targeting just net8 and newer, hopefully solving the assembly mixup. I would try myself, but locally I cannot repro (as pointed out by you in the description)_, and you seem to already have the pipeline that consistently fails.

TY!

@Youssef1313
Copy link
Member

@nohwnd I just tried out 17.14.0-preview-25107-01 and it doesn't work.

@nohwnd
Copy link
Member

nohwnd commented Mar 12, 2025

can you hit me up with some diag logs?
😁

@Youssef1313
Copy link
Member

@nohwnd
my-artifact.zip

@Evangelink
Copy link
Member Author

Is MTP the advised way to run tests these days?

The official stance is that it's a modern alternative to VSTest. Our team owning both platforms is really trying/hoping to have everyone moved over to the new platform. There are many benefits of performance, features and extensibility with the new platform (MTP).

@nohwnd
Copy link
Member

nohwnd commented Mar 12, 2025

Re-reading the thread and the logs, this is .net framework running on mono, as pointed aout above. So there was no change made, we only upgraded the versions of dependencies.

I don't think this will get fixed in vstest, unless there will be massive influx of this types of issues being reported 😔 I also don't think we can drop the dependency because some parts of the platform already use it.

@ericstj
Copy link
Member

ericstj commented Mar 13, 2025

For libraries is it advised to build all the specific framework versions over using a shared .netstandard version? I am using it for some coditional compilation but I guess I could use the VERSION_OR_GREATOR as a replacement in those cases.

I think you'll find multi-targeting to be a better tradeoff for consumption in actual applications. This is what we do for all libraries we build in dotnet/runtime. You can still target netstandard2.0 if you have consumers that you want to target netstandard2.0 but you'll get a better experience, particularly on older versions of .NETFramework, when multi-targeting.

@visschersm
Copy link

Is MTP the advised way to run tests these days?

The official stance is that it's a modern alternative to VSTest. Our team owning both platforms is really trying/hoping to have everyone moved over to the new platform. There are many benefits of performance, features and extensibility with the new platform (MTP).

I managed to replace it and I am now using it in my hobby project. Testing against a bunch of dotnet versions on MSTest, NUnit and XUnit. All running on an ubuntu based action for dotnet framework 461 all the way to dotnet 10. Works like a charm.
Will take the MTP message to my workplace since they are just starting with setting up there testing environments. Might aswell do it on the modern MTP :)

@visschersm thanks for the repro project, can you please update you microsoft.net.test.sdk to 17.14 preview from nuget?

https://www.nuget.org/packages/Microsoft.NET.Test.Sdk/17.14.0-preview-25107-01

There we upgraded the versions and started targeting just net8 and newer, hopefully solving the assembly mixup. I would try myself, but locally I cannot repro (as pointed out by you in the description)_, and you seem to already have the pipeline that consistently fails.

TY!

@nohwnd I just tried out 17.14.0-preview-25107-01 and it doesn't work.

Guess this was already done? Can do it in my repo if you still need it though.

Re-reading the thread and the logs, this is .net framework running on mono, as pointed aout above. So there was no change made, we only upgraded the versions of dependencies.

I don't think this will get fixed in vstest, unless there will be massive influx of this types of issues being reported 😔 I also don't think we can drop the dependency because some parts of the platform already use it.

I guess since I managed to migratie to MTP without any problems I should just use that instead?

@nohwnd
Copy link
Member

nohwnd commented Mar 13, 2025 via email

@Evangelink
Copy link
Member Author

@visschersm thanks for the nice feedback and yes please spread the word!!! Feel free to also say we are really eager to receive any feedback about MTP or MSTest (anything good, bad, missing... code, doc... anything really!).

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

No branches or pull requests

5 participants