-
Notifications
You must be signed in to change notification settings - Fork 5k
Closed
Labels
Staleneeds-more-infoNot enough information has been provided. Please share more detail as requested.Not enough information has been provided. Please share more detail as requested.
Description
I am attempting to move a Windows only .Net Core 3.1 application to .Net Core 6.0
In there I am using this statement:
using (ManagementObjectSearcher searcher = new ManagementObjectSearcher($"SELECT CommandLine FROM Win32_Process WHERE ProcessId={current_process.Id}"))Relevant Packages in use are:
<ItemGroup>
<PackageReference Include="System.Management" Version="6.0.0" />
</ItemGroup>This gives an error
Unhandled exception. System.TypeInitializationException: The type initializer for 'System.Management.ManagementPath' threw an exception.
---> System.TypeInitializationException: The type initializer for 'System.Management.WmiNetUtilsHelper' threw an exception.
---> System.TypeLoadException
at System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointerInternal(IntPtr , Type )
at System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer[TDelegate](IntPtr )
at System.Management.WmiNetUtilsHelper.LoadDelegate[TDelegate](TDelegate& , IntPtr , String )
at System.Management.WmiNetUtilsHelper..cctor()
--- End of inner exception stack trace ---
at System.Management.MTAHelper.IsNoContextMTA()
at System.Management.MTAHelper.CreateInMTA(Type )
at System.Management.ManagementPath.CreateWbemPath(String )
at System.Management.ManagementPath..ctor(String path)
at System.Management.ManagementPath..cctor()
--- End of inner exception stack trace ---
at System.Management.ManagementPath.get_DefaultPath()
at System.Management.ManagementScope._Clone(ManagementScope , IdentifierChangedEventHandler )
at System.Management.ManagementScope._Clone(ManagementScope )
at System.Management.ManagementObjectSearcher..ctor(ManagementScope , ObjectQuery , EnumerationOptions )
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Staleneeds-more-infoNot enough information has been provided. Please share more detail as requested.Not enough information has been provided. Please share more detail as requested.