错误1067 C#Windows服务 [英] error 1067 C# windows service

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

问题描述

我正在执行C#Windows服务.该服务在我的机器上安装并正常运行,但是当我在服务器(Windows Server 2003)上部署并尝试启动该服务时,我得到了可怕的错误1067:应用程序意外终止"!
该怎么办?
一些代码如下所示:

i was doing a C# windows service. the service installs and runs well on my machine, but when i deploy on server (Windows server 2003), and try to start it, i get the dreaded ''Error 1067: application terminated unexpectedly''!
What to do?
some of the code is shown below:

[RunInstaller(true)]
    public partial class MessagingInstaller : Installer
    {
        public MessagingInstaller()
        {
            InitializeComponent();
        }
    }


public partial class MessagingService : ServiceBase
    {
        //declare the message sending logic
        private MessagingLogic msglgc;
        //private readonly EventLog _log = new EventLog { Source = "MessageLogger" };

        public MessagingService()
        {
            InitializeComponent();
        }

        //create new instance of the message sending logic and/or start service
        protected override void OnStart(string[] args)
        {
            if (!EventLog.SourceExists("MessageLogger"))
                EventLog.CreateEventSource("MessageLogger", "Event Logger");

            var _log = new EventLog { Source = "MessageLogger" };

            try
            {
                if (msglgc == null)
                    msglgc = new MessagingLogic();

                msglgc.Start();
            }
            catch (ArgumentException exception)
            { _log.WriteEntry("OnStart Error: " + exception.Message); }
        }

        //stop the service
        protected override void OnStop()
        {
            if (!EventLog.SourceExists("MessageLogger"))
                EventLog.CreateEventSource("MessageLogger", "Event Logger");

            var _log = new EventLog { Source = "MessageLogger" };

            try
            {
                if (msglgc != null)
                    msglgc.Stop();
            }
            catch (ThreadAbortException exception)
            { _log.WriteEntry("OnStop Error: " + exception.Message); }
        }
    }




请帮忙!我需要尽快解决该问题.




Please help! I need the solution as soon as possible

推荐答案

此问题已答复 ^ ].请不要在多个论坛中发布.
This question is already responded to here[^]. Please don''t post in multiple forums.


我敢打赌,您以没有权限写入事件日志的方式安装了该服务.尝试将日志内容作为测试.
I bet you installed the service in such a way that it doesn''t have permission to write to the event log. Try taking the log stuff out as a test.


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

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