Weird Problem With Subscribing To ThreadException Event
I have subscribed my application to receive unhandled exceptions in a custom Error class as below:
Code:
Application.ThreadException += new ThreadExceptionEventHandler(Error.unhandled);
To test I am generating the Exception in the form_load event with:
Code:
throw new Exception("Unhandled Exception!!");
It works really well, until I place a Windows Media Player object on the form, if I do this the Exception is handled normally and not through my custom class.
If I generate the errors when using a command button then there is no problem, unlike in form_load.
I also have found that if I comment out the following line then the exception is handled as I would like:
Code:
((System.ComponentModel.ISupportInitialize)(this.WMP)).EndInit();
note: WMP is the Windows media player object.
Any Ideas? Because Im stumped and also rather irritated by this.
Darren.