Click here to Skip to main content
15,886,137 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
Hi Guys,

I have a bit of an odd scenario and was wondering if you could shed any light on it.
I've written a WPF application that works as a data importer. It uses the MVVM approach and works very nicely.

During development I have implemented try catch's for error handling which catch errors that occur and should display them into the activity log within the application.

The oddness is this:

When the application is running from within Visual Studio, the try catch's are catching errors with no problem. Reading the error message(s) and displaying them to the user as I would expect.
However, when I compile the program and run it on its own by executing the exe file, when the error(s) occur, instead of handling them nicely and cleanly I get a ### has stopped working where ### is the name of the application. It attempts to look for solutions but never succeeds.

Why would my try catches not be working in compiled exe when not run from within visual studio?


Thanks in advance.
Posted
Comments
govardhan4u 24-Feb-14 11:29am    
Have a look on the below article once, if it is useful

http://www.codeproject.com/Articles/90866/Unhandled-Exception-Handler-For-WPF-Applications.aspx

1 solution

It's not that your existing try/catch blocks are not catching the new error. It's the you don't have a try/catch block around the code that is causing the new error. Something in your code is making as assumption that is no longer valid when running outside of the project environment.

I would suggest reading this[^] and, as another example of the technique, this[^].
 
Share this answer
 
Comments
Maciej Los 24-Feb-14 12:42pm    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900