Skip to content

System.Management.dll not working on win-arm64 #81400

Closed

Description

@SteveL-MSFT

Description

This dll works on x64, but fails to load the required native dll on win-arm64. This is impacting the Get-HotFix cmdlet in PowerShell 7.

Reproduction Steps

var scope = new System.Management.ManagementScope(@"root\cimv2");
scope.Connect();

Expected behavior

No error (nothing will happen with this snippet)

Actual behavior

It appears to be trying to load the native library from Framework64 when it should be loading it from FrameworkArm64:

Unhandled exception. System.TypeInitializationException: The type initializer for 'System.Management.WmiNetUtilsHelper' threw an exception.
 ---> System.ComponentModel.Win32Exception (193): Failed to load required native library 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\wminet_utils.dll'.
   at System.Management.WmiNetUtilsHelper..cctor()
   --- End of inner exception stack trace ---
   at System.Management.MTAHelper.IsNoContextMTA()
   at System.Management.MTAHelper.CreateInMTA(Type type)
   at System.Management.ManagementPath.CreateWbemPath(String path)
   at System.Management.ManagementPath..ctor(String path)
   at System.Management.ManagementScope..ctor(String path)
   at Program.<Main>$(String[] args) in C:\Users\slee\test\wmi\Program.cs:line 1

Regression?

Don't know

Known Workarounds

No response

Configuration

.NET 7
Windows 11
arm64

Other information

No response

Activity

  1. ghost added
    untriaged
    on Jan 31, 2023
  2. smasher164 commented on Feb 6, 2023

    @smasher164
    Contributor

    Could be related: #59844

    /cc @ericstj @danmoseley

  3. ViktorHofer commented on Feb 6, 2023

    @ViktorHofer
    Member

    We probably need to update the lookup code that finds the .NET Framework installation (kudos to @ericstj):

    RegistryKey netFrameworkSubKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\.NETFramework\");

  4. added this to the 8.0.0 milestone on Feb 6, 2023
  5. removed
    untriaged
    on Feb 6, 2023
  6. ericstj commented on Feb 6, 2023

    @ericstj
    Member

    If possible, we should also re-enable tests on ARM64 while doing this.

    PlatformDetection.IsNotArmNorArm64Process &&

    This wasn't possible in the past when we didn't have an ARM64 .NETFramework. Now that we do, we should make it work 👍

  7. ericstj commented on Feb 9, 2023

    @ericstj
    Member

    This is likely not a regression, but rather something that never worked but can now that we have an Arm64 .NET Framework. @SteveL-MSFT how urgent is a fix here?

  8. SteveL-MSFT commented on Feb 13, 2023

    @SteveL-MSFT
    ContributorAuthor

    @ericstj I don't think it's super urgent, but the original issue was reported by a customer. If it can be addressed within the next couple of months, I think that would be fine.

  9. Nuklon commented on Feb 27, 2023

    @Nuklon

    Can't we ship that DLL with .NET Core instead? It would be much better than relying on .NET Framework being installed.

  10. SimonCropp commented on Feb 27, 2023

    @SimonCropp
    Contributor

    @SteveL-MSFT

    I don't think it's super urgent, but the original issue was reported by a customer. If it can be addressed within the next couple of months, I think that would be fine.

    Note this was actually reported in Oct 2021 in 59844. so a "couple of months" has definitely passed

  11. JamesWCCheng commented on Mar 1, 2023

    @JamesWCCheng

    I also encountered this problem by using the latest

    [Experimental change]
    If I set registry InstallRoot from C:\Windows\Microsoft.NET\Framework64\ to C:\Windows\Microsoft.NET\FrameworkArm64\

    ARM64 process with WMI works fine.

    I think it's a simple change, I'm looking forward to seeing it gets fixed soon.

  12. 7 remaining items

  13. self-assigned this
    on Mar 13, 2023
  14. ericstj commented on Mar 13, 2023

    @ericstj
    Member

    WMINet_utils is a native binary and I believe requires machine-wide registration/installation to work correctly. It also has never been open sourced, so it would need to go through that process. On top of that the component isn't owned by .NET so it would require some help/permission from the owning team to see that happen assuming such a port was even possible. That's all out of the scope of this issue and tracked by #66386.

  15. Dharmateja-Challa-Dell commented on Mar 14, 2023

    @Dharmateja-Challa-Dell

    I have done few changes as per previous comments, enabled unit test for ARM64, added one test case for this particular issue. Not sure if this solution is correct or not, hence wanted to check, attaching my changes and unit test case and its results in both ARM64 and X64
    .NetCore81400.zip

  16. ViktorHofer commented on Mar 14, 2023

    @ViktorHofer
    Member

    @Dharmateja-Challa-Dell I won't open you attachment. Can you please let me know what your comment refers to?

  17. danmoseley commented on Mar 14, 2023

    @danmoseley
    Contributor

    @Dharmateja-Challa-Dell if you want to share a proposed change please do it by pushing a branch to your fork and sending a link to that.

  18. Silve2611 commented on Mar 15, 2023

    @Silve2611

    This is also a critical error for us. When can we expect for that it will be resolved? Do you have a timeframe?

  19. Dharmateja-Challa-Dell commented on Mar 15, 2023

    @Dharmateja-Challa-Dell

    @Dharmateja-Challa-Dell if you want to share a proposed change please do it by pushing a branch to your fork and sending a link to that.
    Took a fork and added changes to branch
    https://github.com/Dharmateja-Challa-Dell/runtime/branches/

  20. ViktorHofer commented on Mar 15, 2023

    @ViktorHofer
    Member

    Do you have a timeframe?

    As shared above, I'll be working on a fix this week and we will then bring it to our shiproom for backport approval. I can't share when this would then be available but likely not before May.

    EDIT: We got this into the April servicing release so updated packages with the change will be available mid April.

  21. ghost added
    in-pr
    on Mar 16, 2023
  22. ghost removed
    in-pr
    on Mar 16, 2023
  23. SimonCropp commented on Apr 12, 2023

    @SimonCropp
    Contributor
  24. ghost locked as resolved and limited conversation to collaborators on May 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions