启动时,Windows服务会在源(.NET运行时4.0错误报告)错误中引发事件ID(5000)

时间:2012-07-25 08:09:37

标签: windows windows-services

我遇到了一个问题,需要知道是否有人遇到过这个问题。我编写了一个c#windows服务,它调用Web服务(asmx)来执行某些功能。 在本地计算机上部署时,该服务似乎工作正常。但是,当它在远程开发测试环境(Win server 2003)中部署和运行时,会抛出一个错误,该错误被捕获为下面的事件日志。

” 无法找到源(.NET运行时4.0错误报告)中的事件ID(5000)的说明。本地计算机可能没有必要的注册表信息或消息DLL文件来显示来自远程计算机的消息。您可以使用/ AUXSOURCE =标志来检索此描述;请参阅帮助和支持以获取详细信以下信息是事件的一部分:clr20r3,yllddkcpf0zkiftk0gcwtfigwkqck35d,1.0.0.0,50069cd9,tpplc.intranet.applications.incidentreporting.emailingservice,1.0.0.0,50069cd9,d,18a,system.nullreferenceexception,NIL。 “

以下是代码段的剥离但相关版本。

服务的开始 -

      protected override void OnStart(string[] args)
      {

      try

       {           
         //Some initialization code
            …
            …

        //Start the thread to notify email recipients.
            emailThread = new Thread(NotifyRecipients);
            emailThread.Start();
        }
 }


 private void NotifyRecipients()

 {          
 //Now call the web service to fetch the execution time which is actually set from the web app.


       GetEmailSchedule();           

        while (true)
        {                
            // Some Logic               

            //Send email only on the scheduled time of the day AND if the current time matches the 
            //email scheduled time OR if the current hour is greater than the scheduled hour.
            if ((DateTime.Now.TimeOfDay >= executionTime) && (!EmailSent))
            {
                SendMail();// In this method call Email is sent and the EmailSent flag is set to true.
            }
        }
    }

    private void GetEmailSchedule()

     {            
      try
          {                
            LogModule.LogDebug("Calling WebMethod instance to get Email Schedule");

            EmailService.IncidentDetails emailSchedule = new EmailService.IncidentDetails();// Place of error

            emailSchedule.UseDefaultCredentials = true;
            LogModule.LogDebug("Calling WebMethod to get Email Schedule");
            string schedule = emailSchedule.GetEmailSchedule();
            if (string.IsNullOrEmpty(schedule.Trim()))
            {
                //Get the default time from the app.config file to send emails to recipients.

            }
            else
            {
                //Get the individual time components
                string[] scheduleSplit = schedule.Split(',');
                executionHour = Convert.ToInt32(scheduleSplit[0].Trim());
                executionMinute = Convert.ToInt32(scheduleSplit[1].Trim());
            }

            executionTime = new TimeSpan(executionHour, executionMinute, 0);


            //Check if the retrieved exeuction hour or minute has changed from its last execution so that
            //emailsent flag can be reset and email can be sent in the new schedule again.
            if (executionHour != ExecutedHour || executionMinute != ExecutedMinute)
            {
                EmailSent = false;
            }
        }
        catch (Exception ex)
        {
            LogModule.LogError("Error Occurred: " + ex.Message + " ; Inner Exception: " + ex.InnerException.ToString());
            LogEvent("Error Occurred: " + ex.Message + " ; Inner Exception: " + ex.InnerException.ToString(), EventLogEntryType.Error);
            SendExceptionMail(ex);
        }
    }

通过添加自定义日志进行调试时,我意识到在Web服务实例化以调用GetEmailSchedule()方法中的Web方法时会发生这种情况,这是 EmailService.IncidentDetails emailSchedule = new EmailService.IncidentDetails();

不确定为什么会这样。任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

您的网络服务看起来不是问题。在LogEvent方法中发布记录事件的代码。此错误是由于将事件记录在不可用的日志源中。