【问题标题】:Where are my System.Management.* classes?我的 System.Management.* 课程在哪里?
【发布时间】:2010-11-16 12:01:40
【问题描述】:

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

这些类发生了什么?如何访问它们?

【问题讨论】:

  • 也许检查你项目中的引用。它可能存在于一个未添加到您的项目中的项目中。
  • 你引用的是 System.Management.dll 吗?

标签: c# .net visual-studio-2010 .net-4.0


【解决方案1】:

您需要将add a referenceSystem.Management.dll 加入您的项目。

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

【讨论】:

【解决方案2】:

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

我也遇到了同样的问题,然后解决了!

【讨论】:

    【解决方案3】:

    您是否添加了对System.Management 的引用?

    这可能是由于已将框架目标设置为“客户端配置文件”。尝试切换到普通的“4.0 Framework”。

    【讨论】:

    • System.Management.dllSystem.Management.Instrumentation.dll 都包含在客户端配置文件中。您不必针对完整的框架。
    【解决方案4】:

    您是否在项目中添加了对System.Management.dll 的引用?

    【讨论】:

      【解决方案5】:

      添加对System.Management.dll 程序集的引用。 System.Management.ManagementObjectSearcherSystem.Management.ManagementScope 类型都存在于此程序集中。

      您看到其他类型的原因是因为命名空间 System.Management.Instrumentation 中的许多类型都存在于 System.Core.dll 中,通常 Visual Studio 会自动将其作为项目引用包含在内。

      【讨论】:

        【解决方案6】:

        我认为您需要添加对 System.Management.dll 的引用。

        【讨论】:

          【解决方案7】:

          我有 netcore 和 net471 项目。

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

          【讨论】:

            【解决方案8】:

            在您的计算机上找到它 > System.Management.dll

            找到适合您项目的 .NetFrameWork 版本。

            在搜索末尾的文件夹名称中找到 .NetFramework 版本。

            复制文件。

            将其丢弃在项目的“Bin”文件夹中。

            右键单击项目中的引用。

            点击添加参考。

            选择文件(项目根目录 > Bin > System.Management.dll)。

            项目清理和构建。

            【讨论】:

              猜你喜欢
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 1970-01-01
              • 2016-10-04
              • 2011-11-01
              • 1970-01-01
              相关资源
              最近更新 更多