4

Suggestions on resolving this? I keep coming up with "missing" line numbers when consulting the google machine and that isn't the issue we are having. We have a line number but it doesn't point to anything but a closing brace.

Could this be because it is a timeout? It seems strange that it consistently gives up at the very end of the method, and the same method no less. The time outs are not necessarily frequent and the application (win forms calling asmx web service) does timeout in other places at times.

Edit: Code and Stack trace.

public DataSet GetData(...)
{
   // About 18 try/catch blocks loading tables in dataset, all similar to below
   try
   {
      // Create Table Adapter
      // Fill Table
   }
   catch (Exception ex)
   {
      LogError(ex, System.Reflection.MethodBase.GetCurrentMethod(), null);
      throw ex;
   }
}  //Line 479

System.Web.Services.Protocols.SoapException: System.Web.Services.Protocols.SoapException: Server was unable to process request. ---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at MonitoringDataService.AddAllData(DataSet Data, DateTime LastSync, String PrevAreas, String NewAreas, DateTime PrevStartDate, DateTime PrevEndDate, DateTime NewStartDate, DateTime NewEndDate, Int32 CurrentUser, Boolean IsInGroup) in MonitoringDataService.cs:line 479

Worth noting that this is the inner exception.

Grant Thomas
  • 44,454
  • 10
  • 85
  • 129
bdwakefield
  • 685
  • 2
  • 11
  • 24
  • 5
    You forgot to post the code and the stack trace. We can't read it from here. – Cody Gray - on strike Apr 05 '11 at 12:56
  • Was trying not to have to strip out a lot off stuff. Code added. – bdwakefield Apr 05 '11 at 13:12
  • 4
    Yeah, so the real problem is that you have all those try/catch blocks. There's no good reason for that. The second problem is that you're using `throw ex` instead of `throw`. That's been discussed multiple times here already. For example, see [here](http://stackoverflow.com/questions/22623/net-throwing-exceptions-best-practices). Best way to solve the problem is by stripping out all the try/catch blocks and *only* catching the errors that you explicitly handle. There are better ways to log exceptions; you shouldn't do it all inline. – Cody Gray - on strike Apr 05 '11 at 13:15
  • 2
    +1 for help with unnecessary condescension. – bdwakefield Apr 05 '11 at 13:17
  • 2
    I'm sorry, I didn't mean for any of that to be condescending. I suppose referring you to other questions for a discussion of `throw` vs `throw ex` could be seen as condescending, but it's simply that good information has already been provided there. I don't want to duplicate it here, and I couldn't do nearly as good a job as the others who've already posted. – Cody Gray - on strike Apr 05 '11 at 13:19
  • Probably wasn't as bad as it read in my head, at least the "multiple times already"; Moving on though I am all for not duplicating the discussion so that is fine. I would however be more interested in better logging methods. My understanding is this is a pretty homebrew kind of thing and it saves all this information to the database... surprise surprise that table hit 5MM records in a few weeks and basically hosed everything up. – bdwakefield Apr 05 '11 at 13:24

2 Answers2

4

Likely causes:

  • The code that is running is different from the source you are debugging from. This is the most likely cause.
  • Line could be the line after a throw new exception(...)
Aliostad
  • 80,612
  • 21
  • 160
  • 208
  • We have recently republished the web service so option one isn't likely. However the developer had added throw ex after logging the exception. I would imagine given it is a collection of 18+ try/catch blocks... finding the actual root cause is going to be next to impossible. – bdwakefield Apr 05 '11 at 13:13
  • 1
    Not to preach about avoiding `try/catch`, but I do certainly hope they're not embedded within one another. – Grant Thomas Apr 05 '11 at 13:16
  • No, thankfully not embedded. Even I would cry at that. I am not crazy about the way this was written but it is what it is and I have to deal with it now. – bdwakefield Apr 05 '11 at 13:19
  • I am having similar symptoms trying to debug a log file from a customer which has a stack trace in it. The exception is a NullReferenceException, The top 3 items in the stack trace are my application code and all of the line numbers point to the close brace at the end of the function (I know I have the right copy of the source). There are no catch or throw statements anywhere in these functions. Anyone else got any clues? – Andy Apr 13 '16 at 13:13
3

More than likely it's not really erroring on the end brace, but the line before it.

FreeAsInBeer
  • 12,937
  • 5
  • 50
  • 82