Open GitUser200607 opened 5 hours ago
Tagging subscribers to this area: @dotnet/area-system-management See info in area-owners.md if you want to be subscribed.
What's the OS that you are running on? Please share a small repro so that we can diagnose this further.
SystemManagementErrorExample.zip
The problem with <TargetFramework>net6.0-windows10.0.19041.0</TargetFramework>
in file SystemManagementErrorExample.csproj
if I set <TargetFramework>net8.0-windows8.0</TargetFramework>
it runs fine, but for MY project I need windows10.0.19041.
OS: Windows 10 Pro Version 22H2 OS build 19045.5131
Using the 9.0.0 packages with a net6.0 TFM isn't a supported scenario. See the errors below that I get when I build:
PS C:\Users\vihofer\Downloads\SystemManagementErrorExample\SystemManagementErrorExample> dotnet run
C:\Users\vihofer\.nuget\packages\system.codedom\9.0.0\buildTransitive\netcoreapp2.0\System.CodeDom.targets(4,5): warning : System.CodeDom 9.0.0 doesn't support net6.0-windows10.0.19041.0 and has not been tested with it. Consider upgrading your TargetFramework to net8.0 or later. You may also set <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.
C:\Users\vihofer\.nuget\packages\system.management\9.0.0\buildTransitive\netcoreapp2.0\System.Management.targets(4,5): warning : System.Management 9.0.0 doesn't support net6.0-windows10.0.19041.0 and has not been tested with it. Consider upgrading your TargetFramework to net8.0 or later. You may also set <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.
C:\Users\vihofer\.nuget\packages\system.codedom\9.0.0\buildTransitive\netcoreapp2.0\System.CodeDom.targets(4,5): warning : System.CodeDom 9.0.0 doesn't support net6.0-windows10.0.19041.0 and has not been tested with it. Consider upgrading your TargetFramework to net8.0 or later. You may also set <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.
C:\Users\vihofer\.nuget\packages\system.management\9.0.0\buildTransitive\netcoreapp2.0\System.Management.targets(4,5): warning : System.Management 9.0.0 doesn't support net6.0-windows10.0.19041.0 and has not been tested with it. Consider upgrading your TargetFramework to net8.0 or later. You may also set <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.
C:\Users\vihofer\.nuget\packages\system.codedom\9.0.0\buildTransitive\netcoreapp2.0\System.CodeDom.targets(4,5): warning : System.CodeDom 9.0.0 doesn't support net6.0-windows10.0.19041.0 and has not been tested with it. Consider upgrading your TargetFramework to net8.0 or later. You may also set <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.
C:\Users\vihofer\.nuget\packages\system.management\9.0.0\buildTransitive\netcoreapp2.0\System.Management.targets(4,5): warning : System.Management 9.0.0 doesn't support net6.0-windows10.0.19041.0 and has not been tested with it. Consider upgrading your TargetFramework to net8.0 or later. You may also set <SuppressTfmSupportBuildWarnings>true</SuppressTfmSupportBuildWarnings> in the project file to ignore this warning and attempt to run in this unsupported configuration at your own risk.
When I downgrade the package version to 8.0.0 (which supports net6.0), the warnings go away and the app runs successfully. The technical explanation is that when targeting net6.0, the netstandard2.0 System.Management assembly is used instead which doesn't work with net6.0.
So what should I do to evade this error? Downgrade the package?
So what should I do to evade this error?
Ideally you would move to a supported version of .NET, since .NET 6 recently went out of support, either .NET 9 or .NET 8.
The exception is:
But version 8.0.0 does not throw the exception.