Hello,
I am hosting WCF service in console application(just temporary, I will move to service later. Using administrator account). After several hours of execution I get Critical Error from Console(HOST) and my service stop working. What is the best method to trace error? I have tried code below to log error but it seems code do not catch error. I think I need to handle error inside in WCF service not in host application. Any suggestions?
namespace ConsoleApplication1
{
//test host project
class Program
{
static void Main(string[] args)
{
using (var serviceHost = new ServiceHost(new ServicePdf()))
{
try
{
serviceHost.Open();
Console.WriteLine("Service was succesfully hosted. Press [enter] to exit...");
Console.ReadLine();
}
catch (Exception ex)
{
MethodToLogError(ex);
Console.WriteLine("Error occured while hosting service. Press [enter] to exit...");
Console.WriteLine(ex.Message);
Console.ReadLine();
}
}
}
}
}
Regards, Tomas