Welcome to the forums btw.
If you are not using
TryCatchBlocks, then the error will be thrown and the
DoWork event will fire off into the
RunWorkerCompleted event, and it does this because the
DoWork
event can't continue execution of that code.
You need to check the status of the
RunWorkerCompleted
event. To find the result, look in the
RunWorkerCompletedEventArgs.Result Property to see how your event executed.
If the
DoWork
event experienced an error, then this error will be passed on to the
RunWorkerCompleted
Event where you can and should check it first by accessing the
e.Error
property of this event. By checking the
AsyncCompletedEventArgs.Error Property on any Async run code, you can determine if there was in fact an error, and determine what that error was. If you wrap your error code in TryCatchBlocks, then the
e.Error
property will not show any error raised because it was handled or expects it was handled in the TryCatchBlock.
If you are not using TryCatchBlocks in the
DoWork
Event. Any attempts to access any other properties of the
RunWorkerCompleted
events properties will likely return null if an error was passed from your DoWork event, as the only property you will be able to check at such a point is the
e.Error
property, as to ascertain what the problem was that caused the error in your
DoWork
Event.
Given you see errors only in debug mode but you are not seen any errors on your executed code without the debugger attached; is normal. This is also indicative that you are running your code without TryCatchBlocks and your error is running silent through the
RunWorkerCompleted
event.
I will also mark this as answered, since it directly answers your question. I won't be around to answer any questions from today. If you have any, I'm the sure the guys can help you out.