views:

43

answers:

2

Hello. I have this problem which I really cannot understand. I am getting info from a WebClient which misbehaves and returns an empty 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

A: 

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?

Jon Skeet
A: 

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...
}
Palantir
Yeah, I've done that to myself before. When you throw an exception, the debugger points to the very next statement.
Ken Smith