This Windows Service reads email from the MSMQ. It was reading mail when deployed to Windows Server 2003. After being moved to Windows Server 2008, it has stopped reading email. It does not write any logs to the file. When the Windows Service is started, nothing happens.
Please anyone could tell me what could be wrong. Do I need to configure/change any registry value in Windows Server 2008?
Here's the relevant method where logging does NOT occur:
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.");
}
Full code at http://pastebin.com/aiECMTVL