C#窗口服务 [英] c# windows service

查看:219
本文介绍了C#窗口服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个正在运行的窗口服务。我想为监控C#控制台的 Windows服务应用程序 。我的C#控制台应用程序读取并在控制台中的总和,乘写道。 我想打开并使用我的窗口服务与我的控制台应用程序。我应该写什么的中的OnStart()方法为了正确执行我的C#代码。



我把在Windows中从我的控制台应用程序代码服务的exe文件(的Process.Start()),但我有错误:控制台应用程序停止工作。为什么?请帮帮我:)。 我知道Windows服务不与GUI应用程序工作。但我只是想从我的窗口服务打开其他应用程序(EXE我包含我的控制台应用程序)。 THX



有人可以给我一点EQ的作品?:)。 THX


解决方案

这不只是不与Windows服务运行GUI应用程序。控制台应用程序有同样的问题。他们仍然运行一个用户模式进程,到Windows服务无法访问。服务在被称为会话0完全隔离的进程空间中他们没有访问任何用户帐户的桌面,他们不能对这些桌面运行的应用程序进行交互运行。



除此之外,控制台应用程序仍然显示的用户界面。在屏幕上弹出命令提示符窗口仍然被,即使它不是图形。从Windows服务推出,它没有地方流行起来。



这是Windows Vista及更高的安全功能。 启用的服务与桌面交互复选框不工作了,现在也没有,因为Windows XP。你不应该在那里使用它,无论是。隔离保护Windows服务,从源于应用程序代码的攻击。<​​/ p>

像几乎每个其他时间我看到有人问这样的问题,目前还不清楚为什么你需要使用Windows服务摆在首位。更简单的方法是创建一个Windows应用程序,这并不表明任何形式,并在后台运行。这将创建非常类似于Windows服务的效果,但没有限制,您遇到。因为它仍然在当前用户的空间中运行,它可以启动和控制其他用户模式应用程序



相关阅读:



$ b更换Windows服务$ b

I have a running windows service. I would like to monitor a c# console application from the windows service. My c# console application reads and writes in the console a sum, multiplication. I would like to open and work with my console application using my windows service. What should i write in OnStart() method in order to execute properly my c# code.

I did put in windows service the exe file (Process.start()) from my console application code but i have the error: console application stopped from working. WHY? please help me:). I know windows services do not work with GUI applications. But I just want to open from my windows service another application (my exe that contains my console app). THX

Can someone give me a little eq that works?:). Thx

解决方案

It's not just GUI applications that don't work with Windows Services. Console applications have the same problem. They still run as a user-mode process, to which a Windows Service does not have access. Services run in a completely isolated process space called Session 0. They don't have access to the desktop of any user account, and they can't interact with applications running on those desktops.

Aside from that, console applications still show a user interface. The command prompt window that pops up on the screen still counts, even if it's not graphical. Launched from a Windows Service, it has no place to pop up.

This is a security feature of Windows Vista and later. The "Enable service to interact with desktop" checkbox doesn't work anymore, and it hasn't since Windows XP. You weren't supposed to use it there, either. Isolation protects Windows Services from attacks that originate in application code.

Like almost every other time I see people asking questions like this, it's not clear why you need to use a Windows Service in the first place. The simpler option is to create a Windows application that doesn't show any forms, and run it in the background. This creates an effect very similar to a Windows Service, but without the limitations you're experiencing. Because it's still running in the current user's space, it can launch and control other user mode applications.

Related reading:

这篇关于C#窗口服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆