C#Sharp Windows服务 [英] C# Sharp Windows Service

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

问题描述

Beste,

waar ik juist bij huge zit是het volgende

dit是C#中的mijn代码van mijn服务: />


使用System;
使用System.Collections.Generic;
使用System.ComponentModel;
使用System.Data;
使用System.Diagnostics;
使用System.ServiceProcess;
使用System.Text;
使用System.Windows.Forms;
使用SDTRfServer;

命名空间SDTRFServerService
{
公共部分类Service1:ServiceBase
公用{1 >
受保护的重写无效OnStart(string [] args)
{
////EventLog.WriteEntry(Deze服务是gestart !!");


SDTRfServer.frmStatus MyStat = new frmStatus();
MyStat.ShowDialog(); > {{br/> //TODO:在此处添加代码以执行停止服务所需的所有拆卸.
}

}







mijn中的dus ik heb een tweede项目可以通过计算机大步运行daarvan wil ik Laten zien al mijn服务.


Fouten

-在service.msc中启动服务的Volgende功能:

本地计算机上的SrvService服务已启动,然后停止.如果某些服务未被其他服务或程序使用,它们会自动停止[/quote]





-应用程序日志中的Volgende Windows(services.msc中的服务):

服务无法启动. System.InvalidOperationException:当应用程序不在UserInteractive模式下运行时,显示模式对话框或窗体不是有效操作.指定ServiceNotification或DefaultDesktopOnly样式以显示来自服务应用程序的通知.
在System.Windows.Forms.Form.ShowDialog(IWin32Window所有者)
在System.Windows.Forms.Form.ShowDialog()
在C:\ Users \ Niels Pauwels \ Documents \ Visual Studio 2005 \ Projects \ SDTRFServerService \ SDTRFServerService \ Service1.cs:第31行在SDTRFServerService.Service1.OnStart(String [] args)在System.ServiceProcess .ServiceBase.ServiceQueuedMainCallback(对象状态)[/quote]






解决方案

您好,
我不知道您在说哪种语言:),但是模型对话框
MyStat.ShowDialog(); Windows服务中不允许使用. Windows服务不允许以这种方式与用户进行交互!!!

哦,我是从网上得到的,您正在用DUTCH聊天.

让我为您翻译此消息: )使用网络工具

Ik weet niet in welke taal je spreekt :) maar模型Dialoogvenster
MyStat.ShowDialog();在Windows Services中是最新的. Windows服务与您的互动!

哦,在荷兰语中很高兴范式








Beste,

waar ik juist bij vast zit is het volgende

dit is mijn code van mijn service in C#:





using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Windows.Forms;
using SDTRfServer;

namespace SDTRFServerService
{
    public partial class Service1 : ServiceBase
    {
        public Service1()
        {
            InitializeComponent();
        }

        protected override void OnStart(string[] args)
        {
            //EventLog.WriteEntry("Deze service is gestart !!");


            SDTRfServer.frmStatus MyStat = new frmStatus();
            MyStat.ShowDialog();
          
        }

        protected override void OnStop()
        {
            // TODO: Add code here to perform any tear-down necessary to stop your service.
        }

    }







Dus ik heb een tweede project in mijn omgeving geimporteerd en die form daarvan wil ik laten zien als mijn service is gestart op de computer.


Fouten

- Volgende fout als ik de service start in services.msc:

The SrvService service on local computer started and then stoppen. Some services stop automatically if they are not in use by other services or programs[/quote]





- Volgende in de application logs van windows (bij het starten van de service in services.msc):

Service cannot be started. System.InvalidOperationException: Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application.
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at System.Windows.Forms.Form.ShowDialog()
   at SDTRFServerService.Service1.OnStart(String[] args) in C:\Users\Niels Pauwels\Documents\Visual Studio 2005\Projects\SDTRFServerService\SDTRFServerService\Service1.cs:line 31
   at System.ServiceProcess.ServiceBase.ServiceQueuedMainCallback(Object state)[/quote]




Kan iemand helpen aub?

解决方案

Hi,
I don't know in which language you are talking :) but Model Dialog box
MyStat.ShowDialog(); IS NOT ALLOWED in windows services. Windows services are not allowed to interact with user in this way!!!

Oh i got it from net you are talking in DUTCH

Let me translate this message for you :) using web tools

Ik weet niet in welke taal je spreekt:) maar Model Dialoogvenster
MyStat.ShowDialog (); is niet toegestaan in Windows Services. Windows-services zijn niet toegestaan voor interactie met de gebruiker op deze manier!

Oh ik heb het van de netto u spreekt in DUTCH

Laat me vertalen dit bericht voor u:)


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

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