本文介绍了如何显示在窗口服务的形式。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要加载的OnStart()在我的窗口服务方法的一种形式;这里是我的code。这是行不通的。你能提供什么帮助?
保护覆盖无效的OnStart(字串[] args)
{
Form1中FR =新Form1中();
fr.Show();
}
解决方案
您无法使用服务的方式。服务无法与桌面直接交互,因为他们在另一个运行的。您需要创建另一个应用程序将与您的服务进行通信。
如何使通信您可以阅读 MSDN 和的。有些想法也已经描述过的StackOverflow.
I want to load a form in OnStart() method in my windows service; here is my code. It is not working. Can you please provide any help ?
protected override void OnStart(string[] args)
{
Form1 fr = new Form1();
fr.Show();
}
解决方案
You can't use services that way. Services can't interact with desktop directly, because they run in another WindowsStation from the logged in users session. You need to create another application that will communicate with your service.
How to make communication you can read on MSDN and in this example. Some ideas also described already on StackOverflow.
这篇关于如何显示在窗口服务的形式。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!