If it's randomly working/failing it's quite possible you have a race condition in your code, so post up the rest of the code. Running with the debugger could easily trigger the race as compared to running without. What you're explaining makes no sense at the moment, more info is needed