Requirements To Use

Enable System Management capability for your app

Right click Package.appxmanifest > View Code.  In the Capabilities sections add the following line


<iot:Capability Name="systemManagement"/>

If you get a squigle red line "iot not recognised type error" then you need to update the start of the file xmlns as follows (note the 4th xmlns entry-do you have it?  AND the "iot" in IgnorableNamespaces-do you have it?):

<Package
xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10"
xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest"
xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10"
xmlns:iot="http://schemas.microsoft.com/appx/manifest/iot/windows10"
IgnorableNamespaces="uap mp iot">
.
.
.
<Capabilities>
<iot:Capability Name="systemManagement" />
</Capabilities>

You need to have "Windows IoT Extension for UWP" added to your project

Right click on your project. Then, select Add > Reference.. 

Select Universal Windows > Exensions > Windows IoT Extension for the UWP, select the latest version and press OK

Troubleshooting

The Visual Studio implementation of this is flakey, a few tips:

Add the iot:Capability just before any DeviceCapabilities if you have them, e.g. this worked for us:


  <Capabilities>
    <Capability Name="internetClient" />
    <Capability Name="internetClientServer" />
    <uap:Capability Name="removableStorage" />
    <iot:Capability Name="systemManagement" />
    <DeviceCapability Name="serialcommunication">
      <Device Id="any">
        <Function Type="name:serialPort" />
      </Device>
    </DeviceCapability>
  </Capabilities>

Close the Package.appcmanifest and try double clicking it to get the visual designer.  Then re-open it in code view and check everything again – opening in visual mode VS does houekeeping on it and may have changed things like removed your iot from IgnorableNamespace (happened to us!)

Commands

Shutdown

	Windows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Shutdown, TimeSpan.FromSeconds(1));		//Delay is not relevant to shutdown
Restart

	Windows.System.ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Restart, TimeSpan.FromSeconds(1));		//Delay before restart after shutdown

 

UK Electronic Designer
USEFUL?
We benefit hugely from resources on the web so we decided we should try and give back some of our knowledge and resources to the community by opening up many of our company’s internal notes and libraries through mini sites like this. We hope you find the site helpful.
Please feel free to comment if you can add help to this page or point out issues and solutions you have found, but please note that we do not provide support on this site. If you need help with a problem please use one of the many online forums.