开发者

Exception on try?

I have this problem which I really cannot understand. I am getting info from a WebClient which misbehaves and returns an e开发者_Python百科mpty response. This is another issue which I hope to solve soon, but the real problem is the following.

Here is my code:

private void client_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e) {
  if (e.Error != null) {
    //...
  }

  Stream stm;
  try {
    stm = e.Result;
  }
  catch (Exception ex) {
    // debug output
    return;
  }
  WebClient senderWC = (WebClient)sender;
  DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(MapData));

What I get is an exception at the try block. That is, the debugger stops with the arrow pointing to the try line, and highlights the opening braces. Why is that?

See shot: screen shot http://www.freeimagehosting.net/uploads/595d8cad16.jpg


That looks like the kind of debugger oddness you get if the source file being shown doesn't match the pdb. Does it still happen after a full clean and rebuild?


OUCH!!!! Stupid me! After reading it again and again, I noticed that I was throwing that myself! Visible in the screenshot:

if (e.Error != null) {
  visualControl.debug.Text += e.Error.Message;
  throw e.Error.InnerException; // <-- this!! Handle it better, or just return...
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜