0

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?

TheWolf
  • 1,675
  • 4
  • 22
  • 34
  • The error message seems quite clear and to the point. So what's the actual question here? – H H Jul 29 '13 at 17:30
  • Is there a way I could bind to system sleep and resume events in WCF services (perhaps not PowerModeChanged, maybe some other event)? – TheWolf Jul 29 '13 at 17:33

1 Answers1

1

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.

Ehsan
  • 31,833
  • 6
  • 56
  • 65
  • Good suggestion, I was hoping maybe there was another event I could bind to which indicate "suspend" and "resume" states. – TheWolf Jul 29 '13 at 17:35
  • 1
    @vapen i guess this is your only option here. and if it solves your problem you can always mark it as accepted. – Ehsan Jul 29 '13 at 17:40