Skip to content

Unhandled exception. System.MissingMethodException: Method not found: 'System.TimeSpan System.TimeSpan.FromMilliseconds(Int64, Int64)' #1646

@ekalchev

Description

@ekalchev

I am migrating to .net9 and I got this exception when running my test assemblies built with .net9. I am using version nunit3-console 3.19.2 (net8.0)

Unhandled exception. System.MissingMethodException: Method not found: 'System.TimeSpan System.TimeSpan.FromMilliseconds(Int64, Int64)'.
   at System.Windows.Threading.Dispatcher.Invoke(DispatcherPriority priority, Delegate method, Object arg)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)

For other ppl struggling with that - I was able to workaround the error by editing nunit3-console.runtimeconfig.json and manually setting tfm and version to net9.0 and 9.0.0

{
  "runtimeOptions": {
    "tfm": "net9.0",
    "rollForward": "Major",
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "9.0.0"
    },
    "configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
    }
  }
}

This make nunit3-console.exe to use .net9 to run the tests. I believe this happens because there were new overloads of TimeSpan added in .net9 and when the code make use of them, this happens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions