running UI with windows service

为君一笑 提交于 2019-12-07 15:28:55

问题


i am planning to run a launch/monitor a UI application using a windows service(written in C#).with "Allow service to interact with desktop " checked. this works fine with windows xp, but with windows 7 a pop is shown as below

and when i click on view the message , then the whole screen blanks out,with only UI showing up ,as shown below.

is there any way to make it work without the message being shown and screen going blank.

comments/suggestions appreciated.

Regards DEE


回答1:


"Allow service to interact with desktop " is a legacy option that is now highly discouraged, and although it exists, is not expected to work in Windows Vista and upwards.

You need to read a bit on why this is the case in this other SO answer:
Allow service to interact with desktop in Windows

Then look for the alternatives discussed in the answer here:
Alternative to "Allow service to interact with desktop"?

Another discussion outside SO:
http://social.msdn.microsoft.com/forums/en-US/windowssdk/thread/f8f91e8f-5954-43a7-8bc4-80ed2ff1e3b1/




回答2:


In Vista and later, services cannot interact with the desktop. Services run under what is known as session 0 isolation. What you are attempting is simply impossible.

You will have to re-write your application so that the UI part resides in a standard Windows application that runs on the logged in user's desktop. This UI part can communicate with the service by whatever IPC mechanism you prefer.



来源:https://stackoverflow.com/questions/7347464/running-ui-with-windows-service

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!