sjfujiang
Posts: 14
Joined: Wed Nov 25, 2015 1:18 am

how to shutdown pi2b with c#

Mon Dec 14, 2015 3:47 am

how to shutdown pi2b with c#


How to achieve it

sorry,my english.

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: how to shutdown pi2b with c#

Mon Dec 14, 2015 10:21 am

Take a look at the IoTCoreDefaultApp https://github.com/ms-iot/samples/tree/ ... DefaultApp which has this capability and is written in C#. Look at the code under Shutdown/Restart menu entries. Watch out for required capabilities (low level).
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

sjfujiang
Posts: 14
Joined: Wed Nov 25, 2015 1:18 am

Re: how to shutdown pi2b with c#

Mon Dec 14, 2015 12:09 pm

thanks very much.
@ricl

sjfujiang
Posts: 14
Joined: Wed Nov 25, 2015 1:18 am

Re: how to shutdown pi2b with c#

Mon Dec 14, 2015 1:40 pm

thanks,sorry.

ShutdownManager.BeginShutdown(ShutdownKind.Shutdown, TimeSpan.FromSeconds(0.5));

exception :
Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
An exception of type 'System.UnauthorizedAccessException' occurred in AppSpeech.exe but was not handled in user code

sjfujiang
Posts: 14
Joined: Wed Nov 25, 2015 1:18 am

Re: how to shutdown pi2b with c#

Mon Dec 14, 2015 2:23 pm

ricl wrote:Take a look at the IoTCoreDefaultApp https://github.com/ms-iot/samples/tree/ ... DefaultApp which has this capability and is written in C#. Look at the code under Shutdown/Restart menu entries. Watch out for required capabilities (low level).
what's the mean "Watch out for required capabilities (low level)."

ricl
Posts: 657
Joined: Wed Aug 26, 2015 11:55 am

Re: how to shutdown pi2b with c#

Mon Dec 14, 2015 3:05 pm

See in the package manifest

Code: Select all

  <Capabilities>
    <Capability Name="internetClient" />
    <Capability Name="allJoyn" />
    <iot:Capability Name="systemManagement" />
    <iot:Capability Name="lowLevelDevices" />
    <DeviceCapability Name="wiFiControl" />
    <DeviceCapability Name="bluetooth.rfcomm" />
  </Capabilities>
ricl : F/gamma = ma : Law ii(a) : https://climatedatablog.wordpress.com/2016/01/02/an-energy-challenge-2016/ #AnEnergyChallenge2016

sjfujiang
Posts: 14
Joined: Wed Nov 25, 2015 1:18 am

Re: how to shutdown pi2b with c#

Mon Dec 14, 2015 4:07 pm

ricl wrote:See in the package manifest

Code: Select all

  <Capabilities>
    <Capability Name="internetClient" />
    <Capability Name="allJoyn" />
    <iot:Capability Name="systemManagement" />
    <iot:Capability Name="lowLevelDevices" />
    <DeviceCapability Name="wiFiControl" />
    <DeviceCapability Name="bluetooth.rfcomm" />
  </Capabilities>
thanks,it's ok! :D :D :D

First-Coder
Posts: 1
Joined: Mon Aug 01, 2016 7:36 am

Re: how to shutdown pi2b with c#

Mon Aug 01, 2016 7:43 am

Hey,

i have the Raspberry Pi 3 with Windows IoT. I try to add a Shutodown feature in my Application but get also the No Access Exception.

I´ve read that i need to add these Lines in my manifest:

Code: Select all

<iot:Capability Name="systemManagement" />
    <iot:Capability Name="lowLevelDevices" />
But if I will do this i got the compile error:

Code: Select all

Schweregrad	Code	Beschreibung	Projekt	Datei	Zeile	Unterdrückungszustand
Fehler		Namespacepräfix 'iot' wurde nicht definiert.	ptb2	C:\Users\lgund\documents\visual studio 2015\Projects\ptb2\ptb2\Package.appxmanifest	49	
(That means iot is not defined)

Is there any solutions?

Grats
Lukas

soenson
Posts: 2
Joined: Mon Aug 08, 2016 9:46 am

Re: how to shutdown pi2b with c#

Mon Aug 08, 2016 12:07 pm

Hi,
i solve, in file Package.appxmanifest add follow row:

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

In your code add:

ShutdownManager.BeginShutdown(Windows.System.ShutdownKind.Shutdown, TimeSpan.FromSeconds(1));


Does anyone have any solution to reduce the time currently on PI3 are aboute 2 minutes?

axell89
Posts: 2
Joined: Fri Nov 04, 2016 11:13 am

Re: how to shutdown pi2b with c#

Fri Nov 04, 2016 11:17 am

Hello guys,

Regarding shutdown solution discussed above, is it a complete shutdown or the system is restarting after the procedure?

Thanks!

Return to “Windows 10 for IoT”