我的System.Management.*类在哪里?

Tom*_*Tom 19 .net c# .net-4.0 visual-studio-2010

我刚安装了带有.NET Framework 4.0和C#的Visual Studio 2010,System.Management除了for之外,我在命名空间下找不到任何东西System.Management.Instrumentation.MSDN上关于WMI的所有在线文档都告诉我,我必须使用类System.Management.ManagementObjectSearcher或者类,System.Management.ManagementScope但我没有看到这些类.

这些课程发生了什么,我如何访问它们?

Cod*_*ray 33

你需要一个引用添加System.Management.dll您的项目.

您可以在System.Management.Instrumentation不添加引用的情况下看到System.Management.dll它,因为它包含在不同的库中(System.Core.dll自动包含在引用中),但是如果没有显式添加对System.Management.dll库的引用,则无法访问该命名空间包含的其他类型.


小智 6

如果您使用的是VS 2010,请将项目切换到.Net 4.0.然后单击Add References,您将在列表中看到System.Management(而不仅仅是System.Management.Instrumentation).您现在可以使用System.Management类.

我只是遇到了同样的问题,并修复了它!


sus*_*hil 6

我有 netcore 和 net471 项目。

我刚刚下载了System.Management作为官方 Microsoft nuget 插件。