0

私は問題に遭遇し、誰かがそれに直面したかどうかを知る必要がありました. Web サービス (asmx) を呼び出して何らかの機能を実行する ac# Windows サービスを作成しました。ローカル マシンに展開すると、サービスは正常に動作しているようです。しかし、リモート開発テスト環境 (Win サーバー 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."

以下は、削除されたが関連するバージョンのコード スニペットです。

サービスの開始 –</p>

      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 メソッドが呼び出された瞬間に、これが発生することに気付きました。

なぜそれが起こるのか分かりません。どんな援助でも大歓迎です。

4

1 に答える 1

0

Web サービスに問題があるようには見えません。LogEvent メソッド内で、イベントをログに記録するコードを投稿します。このエラーは、使用できないログ ソースにイベントが記録されていることが原因です。

于 2012-07-25T12:36:35.763 に答える