2

切断によって引き起こされた例外をキャッチしようとしている次のコードがあります。

try
{
    DataReaderLoadOperation op = dataReader.LoadAsync((uint)readBuffer.MaxLength());
    await op;  //  <-- Debugger show COMException here
    ReceiveCallback(op, op.Status);
}
catch (COMException e)
{
    Logger.Info("{0} disconnected. (Waiting)", this);
    Logger.Debug("{0} exception = {1}", this, e);
    OnDisconnected();
}

なぜ私のコードはそれをキャッチしないのですか?例外のダンプは次のとおりです。

System.Runtime.InteropServices.COMException occurred   
  HResult=-2147014842   
  Message=An existing connection was forcibly closed by the remote host. (Exception from HRESULT: 0x80072746)   
  Source=mscorlib   
  ErrorCode=-2147014842   
  StackTrace:
       at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
       at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
       at Crystal.IO.Network.SocketClient.<WaitForIncoming>d__4.MoveNext() in d:\Crystal\library\IO\Network\SocketClient.cs:line 479   
  InnerException:
4

1 に答える 1

2

デバッガーの設定を変更して、最初のチャンスの例外で中断しないようにします。

于 2012-05-06T21:50:09.930 に答える