Эта служба Windows читает электронную почту из MSMQ. Он читал почту при развертывании на Windows Server 2003. После переноса на Windows Server 2008 он перестал читать электронную почту. Он не записывает никаких журналов в файл. При запуске службы Windows ничего не происходит.
Пожалуйста, кто-нибудь может сказать мне, что может быть не так. Нужно ли настраивать/изменять какие-либо значения реестра в Windows Server 2008?
Вот соответствующий метод, при котором ведение журнала НЕ происходит:
public void OnStart()
// protected override void OnStart(string[] args)
{
string queuePath = ConfigurationManager.AppSettings["mqPath"];
mailFrom = ConfigurationManager.AppSettings["notificationemail"];
string SMTPSSLConfig = ConfigurationManager.AppSettings["smtpclientssl"];
if (string.IsNullOrEmpty(queuePath))
{
throw new Exception("Message queue path not defined in app.config.");
}
if (string.IsNullOrEmpty(mailFrom))
{
throw new Exception("Sender email used to send notifications is not defined in app.config.");
}
if (string.IsNullOrEmpty(SMTPSSLConfig))
{
throw new Exception("SMTP SSL config not defined in app.config.");
}
objSmtpClient = new SmtpClient();
objSmtpClient.EnableSsl = Convert.ToBoolean(SMTPSSLConfig);
//QueueService.InsureQueueExists(queuePath);
msgQ = new MessageQueue(queuePath);
msgQ.Formatter = new BinaryMessageFormatter();
msgQ.MessageReadPropertyFilter.SetAll();
msgQ.ReceiveCompleted += new ReceiveCompletedEventHandler(msgQ_ReceiveCompleted);
msgQ.BeginReceive();
try
{
if (!MessageQueue.Exists(queuePath))
{
MessageQueue.Create(queuePath);
Log.WriteMessageQueueInitialParamsLog(System.DateTime.Now.ToString()+" :Message queue successfully created at following location:"+queuePath);
}
else
{
Log.WriteMessageQueueInitialParamsLog(System.DateTime.Now.ToString() + ": Message Queue Path: " + msgQ.Path);
}
}
catch (Exception ex)
{
Log.WriteCommonLog(System.DateTime.Now.ToString() + " :Error checking message queue existence:\n"+GetExceptionMessageString(ex));
}
//eventLog1.WriteEntry(System.DateTime.Now.ToString()+" :EmailService started successfully." );
Log.WriteMessageQueueInitialParamsLog(System.DateTime.Now.ToString()+" :Message queue started successfully.");
}
Полный код на http://pastebin.com/aiECMTVL