Frage

I am getting this error when binding to SystemEvents.PowerModeChanged in a WCF service hosted in IIS:

"System event notifications are not supported under the current context. Server processes, for example, may not support global system event notifications."

   at Microsoft.Win32.SystemEvents.EnsureSystemEvents(Boolean requireHandle, Boolean throwOnRefusal)
   at Microsoft.Win32.SystemEvents.add_PowerModeChanged(PowerModeChangedEventHandler value)

Looking online for some solutions but cannot find any. I am assuming this is an issue related to IIS hosting since the service has some layers of separation from the OS?

Are there any other events I could bind to which would indicate system "suspend" and "resume" states?

War es hilfreich?

Lösung

I guess your exception message is self explanatory. global system event notifications are not supported here.

I don't know why you want to do this in IIS. But as you want to so, i would suggest you to write a windows service and communicate with it using something like Named Pipes, MSMQ etc to get such events.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top