question

RobertCrockett-0890 avatar image
0 Votes"
RobertCrockett-0890 asked RobertCrockett-0890 commented

How to use System.Management ManagementObjectSearcher in .net 6

We are upgrading to .Net 6. This code worked fine in .Net 5:

         public static string GetSystemUUID()
         {
             string uuid = "";
             ManagementObjectSearcher Searcher = new ManagementObjectSearcher("SELECT UUID FROM Win32_ComputerSystemProduct");
    
             foreach (ManagementObject WmiObject in Searcher.Get())
             {
                 uuid = WmiObject["UUID"].ToString();
             }
    
             return uuid;
         }

I have upgraded to System.Management to 6.0.0 and upgraded all microsoft extension pacakges and aspnet core packages to .Net 6. I still get the following Exception:

"The type initializer for 'System.Management.ManagementPath' threw an exception."

With this inner exception:

"Built-in COM has been disabled via a feature switch. See https://aka.ms/dotnet-illink/com for more information."




windows-10-application-compatibility
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I also tried installing Microsoft.Windows.Compatibility

0 Votes 0 ·

0 Answers