缺少对 System.Diagnostics.Process 的引用 [英] Missing reference to System.Diagnostics.Process

查看:40
本文介绍了缺少对 System.Diagnostics.Process 的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序来关闭计算机

I have a app that I am building to shut down a computer

我尝试使用使用 System.Management;但它告诉我添加一个引用,添加引用列表中没有这样的东西我尝试使用此代码,但过程中有一个红色波浪形

I tried using using System.Management; but it tells me to add a reference, No such thing in the add reference list I tried using this code but the proccess has a red squigly

System.Diagnostics.Process.Start("Shutdown", "-s -t 10");

关于如何关闭的任何想法?

Any ideas on how to shut down?

推荐答案

对于这样一个令人困惑的问题,有一个简单的解释:您正在使用可移植类库或选择了.NET for Metro 风格应用程序"平台目标.由于不允许使用 Process 类,Metro 应用程序在禁用许多标准 .NET 功能的沙箱中运行.不允许启动另一个进程或关闭操作系统,只有用户可以这样做.

There's one simple explanation for a mystifying problem like this: you are using the Portable Class Libraries or have selected the ".NET for Metro style apps" platform target. Which does not permit using the Process class, Metro apps operate in a sandbox that disables many standard .NET features. Starting another process or shutting down the OS is not permitted, only the user can do that.

如果这对您很重要,您将不得不放弃 Metro,您的应用需要作为桌面应用运行.并且不会在启动 Win8 的平板上运行.

You'll have to give up on Metro if this is important to you, your app needs to run as a desktop app. And won't run on a slate that boots Win8.

这篇关于缺少对 System.Diagnostics.Process 的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆