Skip to content

MissingMethodException raised from System.Management.WmiNetUtilsHelper during wmi call (.NET6 self-contained) #78038

@wzm199309

Description

@wzm199309

Description

SQL IaaS team and are now working on project migration to .NET6, here is an issue we identified with System.Management.WmiNetUtilsHelper during testing which seems to be a known issue, want to seek insights to see how we can resolve it:

Issue: Win32_Service WMI call failed with MissingMethodException  exception raised from 'System.Management.WmiNetUtilsHelper'

Reproduction Steps

Code example:

var mgmtScope = new ManagementScope(ReportingHelpers.StorageWmiCimNamespace);
mgmtScope.Connect();
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Volume where DriveType = 3");
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(mgmtScope, query))
[Warning] ServerConfigurationsManagementStorageReportErrored: System.Exception: Error occurred when attempting to query SQL Server storage report
---> System.MissingMethodException: Cannot dynamically create an instance of type 'System.Management.WbemDefPath'. Reason: No parameterless constructor defined.
   at System.RuntimeType.ActivatorCache..ctor(RuntimeType )
   at System.RuntimeType.CreateInstanceDefaultCtor(Boolean , Boolean )
   at System.Activator.CreateInstance(Type type)
   at System.Management.MTAHelper.CreateInMTA(Type )
   at System.Management.ManagementPath.CreateWbemPath(String )
   at Microsoft.SqlServer.Management.ServerConfigurationsManagement.Common.StorageHelper.GetVolumes()
   at Microsoft.SqlServer.Management.ServerConfigurationsManagement.Queries.SqlQueries.QueryStorageReport(String sqlInstanceName, DrivesStatusMonitor drivesStatusMonitor)
   --- End of inner exception stack trace ---

Expected behavior

WMI call should works

Actual behavior

instead, raising exception

Regression?

No response

Known Workarounds

No response

Configuration

.NET6, windows server 2019, x64

Other information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions