System.Management: unable to get instance of Msvm_VirtualSystemManagementService #87095
-
.NET 7.0 project created through Template Studio for WinUI Unable to get instance of Msvm_VirtualSystemManagementService: managementObjectCollection contains no objects. ManagementScope scope = new ManagementScope(@"root\virtualization\v2");
using (ManagementClass managementServiceClass = new ManagementClass("Msvm_VirtualSystemManagementService"))
{
managementServiceClass.Scope = scope;
ManagementObjectCollection managementObjectCollection = managementServiceClass.GetInstances();
if (managementObjectCollection.Count == 0)
{
throw new ArgumentException("The collection contains no objects", "collection");
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 11 replies
-
Can you reduce to simplest standalone repro code? Does it work on .NET Framework? |
Beta Was this translation helpful? Give feedback.
-
Problem solved. Required to run as administrator. In the case of WinUI, it is not enough to run Visual Studio with administrator rights and you need to change the project settings. |
Beta Was this translation helpful? Give feedback.
Problem solved. Required to run as administrator. In the case of WinUI, it is not enough to run Visual Studio with administrator rights and you need to change the project settings.