dotnet/runtime

WMI - Expand PlatformNotSupported_FrameworkUpdatedRequired error coverage

Open

#39,488 opened on Jul 16, 2020

View on GitHub
 (9 comments) (0 reactions) (0 assignees)C# (5,445 forks)batch import
area-System.Managementenhancementhelp wanted

Repository metrics

Stars
 (17,886 stars)
PR merge metrics
 (Avg merge 12d 11h) (661 merged PRs in 30d)

Description

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.

Contributor guide