简体   繁体   中英

Service Start and stop in Universal Windows App

I found the following Links in MSDN to help me start and stop the window services. There is code snippet which tells it is possible to start and stop the service.

ServiceController sc = new ServiceController("Telnet");
if  ((sc.Status.Equals(ServiceControllerStatus.Stopped)) 
        ||  (sc.Status.Equals(ServiceControllerStatus.StopPending)))
{
     sc.Start();
}  
else
{
  sc.Stop();
}  
sc.Refresh();

for this i need the System.ServiceProcess.dll the dll.

Namespace : System.ServiceProcess Assembly : System.ServiceProcess (in System.ServiceProcess.dll)

I am trying to add this from NUget and got the error.

Type Script command : Install-Package System.ServiceProcess.ServiceController -Pre

Error Message :

Install-Package : System.ServiceProcess.ServiceController 4.1.0-beta-23516 provides a compile-time reference assembly for System.ServiceProcess.ServiceController on UAP,Version=v10.0, but there is no run-time assembly compatible with win10-arm. At line:1 char:1 + Install-Package System.ServiceProcess.ServiceController -Pre + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Install-Package], Exception + FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.InstallPackageCommand

This namespace System.ServiceProcess cannot be supported in uwp. We cannot find this .Net api in .NET for UWP apps .

Also you can add this reference manually by download the package from System.ServiceProcess.ServiceController . But you will still receive error when you run the code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM