我在控制檯應用程序中託管WCF服務(只是暫時的,稍後我將使用管理員帳戶遷移到服務中)。經過幾個小時的執行,我從控制檯(HOST)得到嚴重錯誤,我的服務停止工作。跟蹤錯誤的最佳方法是什麼? 我曾嘗試下面的代碼來記錄錯誤,但它似乎代碼不捕獲錯誤。我想我需要在WCF服務中處理錯誤,而不是在主機應用程序中。 有什麼建議嗎?WCF服務中的嚴重錯誤
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();
}
}
}
}
}
問候, 托馬斯