Skip to content

MissingMethodException when running tests on Mono after bumping to .NET SDK 9.0.300 #116518

Closed
@jamescrosswell

Description

@jamescrosswell

Description

After bumping from .NET SDK 9.0.204 to 9.0.300, when an assembly containing code to be tested targets a different version of the .NET Framework than the one being used by the test runner, and the tests are run on Mono (e.g. on macOS or Linux), tests fail with an error like:

System.MissingMethodException : Method not found: Sentry.HttpStatusCodeRange Sentry.HttpStatusCodeRange.op_Implicit(System.ValueTuple`2<int, int>)
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <d636f104d58046fd9b195699bcb1a744>:0

When running the same tests using .NET SDK 9.0.204, the same problem does not occur.

Reproduction Steps

See minimal repro at:

Basically clone and run dotnet test from the root folder of that repository on a machine running macOS or Linux (with Mono installed, obviously - I've got 6.14.1 installed on my machine, via homebrew... we see the same behaviour on macOS github runners).

Expected behavior

Expect the tests to pass.

Actual behavior

The tests fail with the error:

MonoReproTests.HttpStatusCodeRangeTests.HttpStatusCodeRange_Excludes_AboveEnd (4ms): Error Message: System.MissingMethodException : Method not found: MonoRepro.HttpStatusCodeRange MonoRepro.HttpStatusCodeRange.op_Implicit(System.ValueTuple`2<int
      , int>)
      Stack Trace:
        at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
        at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <42d7e5fae301407c8
      838152bf797a00b>:0

Regression?

This was not a problem in .NET SDK 9.0.204 and earlier. You can see an example of a much more complex solution that has different versions of the .NET Framework in the SDK and test projects in the sentry-dotnet repository (where this issue was first discovered). Version 5.10.0 of the Sentry SDK is targeting net462, while the tests for the same version are targeting net48 (just as in this minimal repro).

Known Workarounds

No response

Configuration

  • .NET 9.0.5
  • macOS 15.5 (24F74)
  • Silicon M2 (Arm64)

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs-area-labelAn area label is needed to ensure this gets routed to the appropriate area owners

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions