0

我有作为 Windows 服务器运行的 web 服务(在测试机器上)。有时它会崩溃(这是小问题)。大问题是当它崩溃时,知道发生了什么的信息很少。在事件查看器中像这样:

EventType clr20r3、P1 mywebservice.exe、P2 1.0.5085.19354、P3 529d9a15、P4 mscorlib、P5 2.0.0.0、P6 5040540e、P7 e2、P8 10、P9 system.invalidoperationexception、P10 NIL。

这是启动过程的代码。如果我尝试throw InvalidOperationException()从不同的代码位置手动操作,则会处理异常。

static void Main(string[] args)
{
   try
   {
      MainLow(args);
   }
   catch (Exception ex)
   {
      Log.Error(ex);
      throw;
    }
 }
4

1 回答 1

0

You need to trap errors in the Start method of the service class, not in Main.

Cheers -

于 2013-12-18T12:41:18.313 回答