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?
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.
Related
To be clear there are no Errors for the hosted service, just a generic Windows service error.
The error message says:
Error 1053: The service did not respond to the start or control request in a timely fashion.
If I run NServiceBus.Host explicitly (where the windows service is installed) I am presented with relevant messages indicating a successful "spinning up" of the end point, and, in fact, I can see subscription message(s) are persisted into a relevant private MSMQ queue and the exe then sits and waits, like a good server should, for something to happen upon it.
If I start the windows service (hosting the endpoint) there are no exceptions or events in the event viewer, or entries in the log file to indicate any errors or give me reason to believe something bad is happening. If I look in the log file and queue I can see subscription messages are indicated as dispatched, in effect, the same behavior as running it standalone, with the only difference being that the service wont start.
EDIT:
The windows service is provided by the NServiceBus framework in the form of a generic host, and therefore implementation of the various required windows service methods is not something I have control of, which you would normally have if you were creating the windows service yourself.
The most common reason that I've found for this is down to logging.
The user account running the service must have Performance Monitoring Access.
I add this through Server Manager > Users & Groups > Groups > Performance Log Users > Add.
Our desktop application require to be updated directly when a mobile employee sends any message from his/her windows phone 7 mobile.
Currently our requirement is that send a message from our desktop application to a Windows Phone 7.5 which we are able to achive easily using PUSH Notifications, Now when the user takes some action against the sent message the windows phone app calls the WCF service and pass the message to that WCF which receives the message and puts into the database and application reads it later and this is where problem lies. Because our WCF is putting that message into database our application is polling it every 5 second and if any replies received from any of our drivers then it is updating the UI.
What we want to achieve is when we receive any reply our desktop applicaton should be notified automatically and udpates the UI and then put it into the database.
So please share your experience on this issue.
Thanks
Why not update the WCF service to notify any registered "listeners" (i.e. running instances of your client app) that the database has been updated with new information?
You could do this by having your service expose a service that can be called by clients wanting to register for some/all event types. The client app(s) host a service implementing a callback contract that the service can call when the registered events are raised.
There's a good MSDN article one-way, callback and pub-sub messaging with WCF: http://msdn.microsoft.com/en-us/magazine/cc163537.aspx.
Be sure to keep track of and throttle how many events your client app is receiving per second - the last thing you want to have happen is for 100 client apps to all hit the server 50 times each if 50 events are raised sumultaneously!
Richard's solution is probably more proper, since it describes using nicely packaged WCF APIs that will do a lot for you. Another way could be to implement long-polling yourself. You could then also update your Windows Phone clients when they need to receive an immediate update. I wrote an article on that some time ago which you can find if you google long polling on Windows Phone.
I have a mobile applciation thats interacts with a server. The mobile application should be allowed to do a http posting to the server.
The server should be able to handle the event and display out using a custom windows .net application on the server almost immediately based on event.
The http post will be in a asp.net webpage. From this page what type of application of event handling should i be used so that it can trigger a custom code in a c# windows application that i will be coding.
So what are the right ways to do it?
Is there any event handling that works on c#.net that can be applied on the above scenario?
So far i only thought of msmq event handling. The mobile app does a http post on the server, the server creates a msmq on the server side and the windows applications listens for the new msmq message.
you can use WCF to communicate with the desktop app.
It supports callbacks and events, which is exactly what you need.
see here.
I have a Windows Service (not a webservice) and I need to provide some security. ie. Only authorise users run methods of the service.
Is it possible to use certificates like you can do for webservices? Can anyone describe the process of how one would go about doing this?
Thanks!
Caveat : I have not done this before but it seems like one possible solution.
Create a WCF service and host it as a Windows Service.
There is a tutorial on MSDN as to how you can do that
You can use TCP / named Pipes to communicate and can configure security for either of these based on the security options options in WCF i.e.
Transport
Message
Combination of Transport and Message
TransportWithMessageCredential
TransportCredentialOnly
For details on each of the security options above and how to use them you can also check out this article
You need windows service in a scenario where you want to do some continuous processing irrespective of user logged in. Your windows service would be running/processing even if no user is logged into system. To add on to this, windows service doesn't expose bunch of methods. It only gives you events like OnStart, OnStop so that you can control your service through Services.msc. In OnStart you merely fires off your business logic and keep doing it until you stop the windows service.
Probably windows service is not the right solution for your scenario.
I'm trying to create a feedback system which all messages get posted to then published back to the correct subsystem. We are using queues quiet heavily and i want to make the subscriber code as clean as possible. I want to switch based off the message id i get into the feedback system and publish to its specific subscriber. i don't want to make a service for each subscriber to listen for messages.. i was thinking i could set up a queue for each subscriber and trigger to invoke a com+ component.. but i'm looking for a more modern way..
I was looking into NServiceBus but it seems i'd need to make a service/executable/webservice for each listening system ( its a little less work to make a C# dll and invoke a method) and i'm not sure if NServiceBus can handle dynamic endpoints based off a preloaded config ( loaded from a db ). WCF is also a choice.. it can handle dynamic endpoints for sure..
what do you think is the best solution for the lease amount of code/ scalable for new systems to subscribe?
Thanks
In case you are ok with online solutions you could take a look at the latest .NET Services SDK for Windows Azure which has queue service bus http://www.microsoft.com/azure/netservices.mspx It relies on WCF messages and supports routing etc. Some blog posts about this here http://vasters.com/clemensv/default.aspx
Another framework you could try is MassTransit http://code.google.com/p/masstransit/
It seems you're looking for a service host, rather than a message broker. If so, Microsoft's recommended way is to host your WCF services in IIS. They can still use MSMQ as transport, but the services themselves will be managed by IIS. IIS has evolved significantly since its early days as HTTP server, now it's closer to an application server, with its choice of transports (TCP, MSMQ, HTTP), pooling, activation, lifetime policies etc.
Although I find WCF+MSMQ+IIS somewhat overcomplicated this is the price you pay to play on the Microsoft field.
For nice and simple message broker, you can use Active MQ instead of MSMQ, it will give you message brokering as well as pub/sub. It's quite easy to work with in .NET, check this link out: http://activemq.apache.org/nms/