Search code examples
c#iotsystemmanagement

Shutdown IoT device from code


What I have is: VS 2017 Community, C#, Raspberry 3, IoT-Extension referenced. I want to shutdown the Raspberry from code. What I have found on the web everywhere is this: Edit the AppManifest. Add ...IgnorableNamespaces="uap mp iot"> (- which already was there when I looked into it) Then add:

<iot:Capability Name="systemManagement"/>

But: "iot:Capability" stays undercurled, saying, that it "has invalid child element 'Capabilities' in namespace 'http:... appX/manifest/iot/win10'

I had already 2 other capabilites selected

<Capability Name="internetClient" />
<Capability Name="privateNetworkClientServer" />

Can they interfere? I could not find this error somewhere else on the whole web. Would be great if someone had an explanation for this. Thanks in advance!


Solution

  • To use ShutdownManager to manages the shutdown of devices, you need:

    1. Reference Windows IoT Extension SDK (v10.0.10240.0 or later)
    2. Add the following to application Package.appmanifest: <iot:Capability Name="systemManagement"/>
    3. Add this name space: using Windows.System;

    For more detailed information, see ShutdownManager Class.