Friday, March 9, 2012

Diagnostic or debug info

I'm trying to track down a thorny bug in SqlCE that just crashes randomly without any apparent correlation with anything. I was wondering if there is any diagnostic flags/TraceListener setting/debug info that I can turn on to see if I can find any patterns.
To get as much information as possible from a SqlCe error, traverse the SqlCe error collection to get each SqlCeError, see this sample (for managed codeSmile http://msdn2.microsoft.com/en-us/library/ms174079.aspx|||
Unfortunately, the exception occurs outside my code. I cannot place a try/catch around it.

I'm just looking for diagnostics to track down the error. For example, with Linq I can turn on some debug info with:

Code Snippet

MyDataContext db = new MyDataContext (@."mydb.sdf");
db.Log = System.Console.Out;
db.Connection.StateChange+=new StateChangeEventHandler(Connection_StateChange);



Can more be done?

|||

Not much more can be done, unless you add more tracing to your code to determine the state of the app when the crash happens.

|||Maybe you are encountering on of the rare SL CE bugs, like to the one reported here: http://www.pluralsight.com/blogs/jimw/archive/2007/09/04/48361.aspx|||
Yep, it's a random AccessViolationException that kills the entire app.
|||The problem may be related to multi-threading, which would explain the randomness.

I've changed the code to guarantee a unique db connection per thread and things *seem* to work...for now.

No comments:

Post a Comment