缺少参照的System.Diagnostics.Process [英] Missing reference to System.Diagnostics.Process
问题描述
我有我建立关闭计算机
我试着用用System.Management
A的应用程序;
,但它告诉我添加引用,添加引用列表
没有这样的事情,我尝试使用此代码,但proccess有一个红色的squigly
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?
推荐答案
有对这样一个神秘问题的一个简单的解释:您正在使用便携式类库或选择了Metro风格应用平台的目标.NET。它不允许使用Process类,地铁应用在禁用许多标准.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.
您将不得不放弃对地铁如果这对你很重要,你的应用程序需要作为一个桌面应用程序运行。而不会在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屋!