question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RuntimeInformation and OSPlatform class does not exist after Upgrading to .NET5.0

See original GitHub issue

I do not know if this is a good place for this issue or not, but after updating the Microsoft.Extensions.DependencyInjection.Abstractions to version 5.0.0 it does not recognize the RuntimeInformation and OSPlatform classes.

This repo can reproduce this problem.

The strange thing is that these classes are available in versions 4.5 and 4.7, but not in 4.6!

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
eerhardtcommented, Nov 12, 2020

Thanks for the investigation, @joperezr. I’m going to close this issue as “by design” since there isn’t a change needed in our NuGet packages.

@mjebrahimi - like @joperezr mentions above, you can resolve this by adding a PackageReference to https://www.nuget.org/packages/System.Runtime.InteropServices.RuntimeInformation. Thanks for reporting the issue. This information can unblock someone else if they run into the same problem.

1reaction
joperezrcommented, Nov 12, 2020

Actually just looked at it again and what was happening here before (and the reason why it worked) is that when folks used this package in net461 it was causing the netstandard facades to be includded in your project, which in this particular case was helping resolve these two types. That is why @eerhardt you don’t see a dependency explicitly on the RuntimeInformation package but it was still getting pulled in. Now this package doesn’t require the netstandard facades any longer (also resulting in your bin output folder for net461 to be much cleaner 😄) but that is also meaning in this particular case that these two types are not resolving. As explained above, a simple package Reference to the RuntimeInformation package should resolve this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Determine Operating System in .NET Core
Method. System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform(). Possible Argument. OSPlatform.Windows OSPlatform.OSX OSPlatform.
Read more >
CA1416: Validate platform compatibility (code analysis)
A violation only occurs if the project does not target the supported platform ( net5.0-differentPlatform ). This also applies to multi-targeted ...
Read more >
Platform compatibility analyzer
A Roslyn analyzer that can help detect platform compatibility issues in cross-platform apps and libraries.
Read more >
System.Runtime.InteropServices.RuntimeInformation 4.3.0
Provides APIs to query about runtime and OS information. Commonly Used Types: System.Runtime.InteropServices.RuntimeInformation System.
Read more >
Migrating from .NET Framework to .NET Core: Tips and Tricks
NET Core console app. The results were the same when running the console app on Windows and Mac. Thus, when a library does...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found