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.

貢獻者指南