dotnet/runtime

WMI - Expand PlatformNotSupported_FrameworkUpdatedRequired error coverage

Open

#39,488 创建于 2020年7月16日

在 GitHub 查看
 (9 评论) (0 反应) (0 负责人)C# (5,445 fork)batch import
area-System.Managementenhancementhelp wanted

仓库指标

Star
 (17,886 star)
PR 合并指标
 (平均合并 12天 11小时) (30 天内合并 661 个 PR)

描述

Description

Issue https://github.com/dotnet/runtime/issues/24536 outlined an exception where WMI would fail to work correctly if the machine has an old .NET Framework version installed. https://github.com/dotnet/corefx/pull/26137 improved the situation by adding a better error message. It appears that this "fix" does not cover all cases as a customer reported this exception to me today: The type initializer for 'System.Management.ManagementPath' threw an exception. -> The type initializer for 'System.Management.WmiNetUtilsHelper' threw an exception.

Configuration

Customer specs are:

  • Windows 7 32-bit
  • .NET Framework 4.5
  • .NET Core 3.1.5
  • System.Management package 4.7.0

Other information

The customer was able to resolve the problem by upgrading to .NET Framework 4.8. I would like to request that the PlatformNotSupported_FrameworkUpdatedRequired error coverage be extended to support this scenario so a better error message is presented.

I believe this code is what causes the exception to occur:

var diskSearcher = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
diskSearcher.Get();

Also, a question: What is the minimum .NET Framework version for WMI to work correctly? So I can check for it and warn the user.

贡献者指南