Skip to content
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

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

Closed
ekalchev opened this issue Mar 13, 2025 · 3 comments

Comments

@ekalchev
Copy link

ekalchev commented Mar 13, 2025

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.

@stevenaw
Copy link
Member

Thanks for your issue report and sharing your work around. The 3.19 console runner does not contain a .NET 9 agent and so you're quite right that .NET 9-specific overloads like this will unfortunately error. A change has just recently merged to fix this in #1602 by adding a new .NET 9 runner in the upcoming 3.20 release.

@ekalchev The changes should be in this alpha release. Can you see if it works for you?
https://www.myget.org/feed/nunit/package/nuget/NUnit.ConsoleRunner/3.20.0-alpha.1

@ekalchev
Copy link
Author

@stevenaw
Copy link
Member

Thanks for testing that out @ekalchev . Glad to hear the 3.20 release will fix this for you. We're just finalizing the release now, we aim to release within the coming weeks

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

2 participants