Skip to content

System.Management doesn't work on Windows versions without .NETFramework #45143

Closed

Description

@ericstj

AB#1249431

Description

System.Management requires wminet_utils.dll in order to perform must of it's functionality, however this component is missing on some SKUs / architectures of Windows which do not include .NETFramework (eg: ARM64, and others)

string wminet_utilsPath = Path.Combine(
netFrameworkInstallRoot,
CompatSwitches.DotNetVersion, // The same value is hard coded on Environment.Version and quirks for WMI
"wminet_utils.dll");
IntPtr hModule = Interop.Kernel32.LoadLibrary(wminet_utilsPath);
if (hModule == IntPtr.Zero)
{
// This is unlikely, so having the TypeInitializationException wrapping it is fine.
throw new Win32Exception(Marshal.GetLastWin32Error(), SR.Format(SR.LoadLibraryFailed, wminet_utilsPath));
}
if (LoadDelegate(ref ResetSecurity_f, hModule, "ResetSecurity") &&
LoadDelegate(ref SetSecurity_f, hModule, "SetSecurity") &&
LoadDelegate(ref BlessIWbemServices_f, hModule, "BlessIWbemServices") &&
LoadDelegate(ref BlessIWbemServicesObject_f, hModule, "BlessIWbemServicesObject") &&
LoadDelegate(ref GetPropertyHandle_f27, hModule, "GetPropertyHandle") &&
LoadDelegate(ref WritePropertyValue_f28, hModule, "WritePropertyValue") &&
LoadDelegate(ref Clone_f12, hModule, "Clone") &&
LoadDelegate(ref VerifyClientKey_f, hModule, "VerifyClientKey") &&
LoadDelegate(ref GetQualifierSet_f, hModule, "GetQualifierSet") &&
LoadDelegate(ref Get_f, hModule, "Get") &&
LoadDelegate(ref Put_f, hModule, "Put") &&
LoadDelegate(ref Delete_f, hModule, "Delete") &&
LoadDelegate(ref GetNames_f, hModule, "GetNames") &&
LoadDelegate(ref BeginEnumeration_f, hModule, "BeginEnumeration") &&
LoadDelegate(ref Next_f, hModule, "Next") &&
LoadDelegate(ref EndEnumeration_f, hModule, "EndEnumeration") &&
LoadDelegate(ref GetPropertyQualifierSet_f, hModule, "GetPropertyQualifierSet") &&
LoadDelegate(ref Clone_f, hModule, "Clone") &&
LoadDelegate(ref GetObjectText_f, hModule, "GetObjectText") &&
LoadDelegate(ref SpawnDerivedClass_f, hModule, "SpawnDerivedClass") &&
LoadDelegate(ref SpawnInstance_f, hModule, "SpawnInstance") &&
LoadDelegate(ref CompareTo_f, hModule, "CompareTo") &&
LoadDelegate(ref GetPropertyOrigin_f, hModule, "GetPropertyOrigin") &&
LoadDelegate(ref InheritsFrom_f, hModule, "InheritsFrom") &&
LoadDelegate(ref GetMethod_f, hModule, "GetMethod") &&
LoadDelegate(ref PutMethod_f, hModule, "PutMethod") &&
LoadDelegate(ref DeleteMethod_f, hModule, "DeleteMethod") &&
LoadDelegate(ref BeginMethodEnumeration_f, hModule, "BeginMethodEnumeration") &&
LoadDelegate(ref NextMethod_f, hModule, "NextMethod") &&
LoadDelegate(ref EndMethodEnumeration_f, hModule, "EndMethodEnumeration") &&
LoadDelegate(ref GetMethodQualifierSet_f, hModule, "GetMethodQualifierSet") &&
LoadDelegate(ref GetMethodOrigin_f, hModule, "GetMethodOrigin") &&
LoadDelegate(ref QualifierGet_f, hModule, "QualifierSet_Get") &&
LoadDelegate(ref QualifierPut_f, hModule, "QualifierSet_Put") &&
LoadDelegate(ref QualifierDelete_f, hModule, "QualifierSet_Delete") &&
LoadDelegate(ref QualifierGetNames_f, hModule, "QualifierSet_GetNames") &&
LoadDelegate(ref QualifierBeginEnumeration_f, hModule, "QualifierSet_BeginEnumeration") &&
LoadDelegate(ref QualifierNext_f, hModule, "QualifierSet_Next") &&
LoadDelegate(ref QualifierEndEnumeration_f, hModule, "QualifierSet_EndEnumeration") &&
LoadDelegate(ref GetCurrentApartmentType_f, hModule, "GetCurrentApartmentType") &&
LoadDelegate(ref GetDemultiplexedStub_f, hModule, "GetDemultiplexedStub") &&
LoadDelegate(ref CreateInstanceEnumWmi_f, hModule, "CreateInstanceEnumWmi") &&
LoadDelegate(ref CreateClassEnumWmi_f, hModule, "CreateClassEnumWmi") &&
LoadDelegate(ref ExecQueryWmi_f, hModule, "ExecQueryWmi") &&
LoadDelegate(ref ExecNotificationQueryWmi_f, hModule, "ExecNotificationQueryWmi") &&
LoadDelegate(ref PutInstanceWmi_f, hModule, "PutInstanceWmi") &&
LoadDelegate(ref PutClassWmi_f, hModule, "PutClassWmi") &&
LoadDelegate(ref CloneEnumWbemClassObject_f, hModule, "CloneEnumWbemClassObject") &&
LoadDelegate(ref ConnectServerWmi_f, hModule, "ConnectServerWmi") &&
LoadDelegate(ref GetErrorInfo_f, hModule, "GetErrorInfo") &&
LoadDelegate(ref Initialize_f, hModule, "Initialize"))
{
// All required delegates were loaded.
Initialize_f(CompatSwitches.AllowIManagementObjectQI);
}
else
{
LoadPlatformNotSupportedDelegates(SR.Format(SR.PlatformNotSupported_FrameworkUpdatedRequired, wminet_utilsPath));
}

Activity

  1. added
    untriaged
    on Nov 24, 2020
  2. added this to the 6.0.0 milestone on Nov 24, 2020
  3. ericstj commented on Nov 24, 2020

    @ericstj
    MemberAuthor

    Note that the original authors of this component recommend MMI as a replacement: #24803 (comment)

    The latest version of this package does support ARM64:
    https://www.nuget.org/packages/Microsoft.Management.Infrastructure/

    @SteveL-MSFT do you know of anyone porting from System.Management to MMI: is it straight forward?

  4. danmoseley commented on Dec 2, 2020

    @danmoseley
    Contributor

    some SKUs / architectures of Windows which do not include .NETFramework (eg: ARM64, and others)

    For non ARM64 - I assume you mean Windows Nano? I don't think we've gotten feedback on that gap so I guess ARM64 is the interesting case.

  5. removed
    untriaged
    on Dec 3, 2020
  6. danmoseley commented on Jun 8, 2021

    @danmoseley
    Contributor

    @ericstj should we close this, or at least it should move out of 6.0

  7. modified the milestones: 6.0.0, Future on Jun 8, 2021
  8. ericstj commented on Jun 8, 2021

    @ericstj
    MemberAuthor

    Agreed on moving to future.

  9. danmoseley commented on Aug 5, 2021

    @danmoseley
    Contributor

    I'm going to close this as there's no longer a partner ask and it's a legacy tech.

  10. ghost locked as resolved and limited conversation to collaborators on Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions