1

I have created a vb.net program and released it to the customer. They are running the exe and at times the program crashes unexpectedly and display the message: "... has encountered a problem and needs to close"

I know I should have added code to handle the exception, but is there a way that I can find out which line in the program caused the error? What is generally as good way to track errors in a program after it has been released?

Thanks

Kritz
  • 7,099
  • 12
  • 43
  • 73
  • You need to implement the error handling mechanism in your code and release a new build or replace the exe in update. – Harsh Feb 07 '12 at 11:20
  • http://stackoverflow.com/a/5049241/284240 It might also be helpful to see the customer's windows application log. – Tim Schmelter Feb 07 '12 at 11:25
  • 1
    Too late, you are down to luck and guesswork now. Large slice of humble pie, new version with a trap and log / display. look up Application.ThreadException and AppDomain.UnhandledException. You can try the it may be something in your environment (more than possible it is), so as you are a good customer, I've tireless worked at a new version with enhanced logging and checking in order to identify the issue, as opposed to "my bad sorry I messed up". Don't worry we all did this one once.... – Tony Hopkinson Feb 07 '12 at 11:27
  • The program was developed just for one customer, so I can supply them with a new exe. I'll take a look at the application log and improve the error handling. – Kritz Feb 07 '12 at 11:55
  • 1
    possible duplicate of [Deciphering the .NET clr20r3 exception parameters P1..P10](http://stackoverflow.com/questions/4052770/deciphering-the-net-clr20r3-exception-parameters-p1-p10) – Hans Passant Feb 07 '12 at 12:12
  • Thanks Hans, that will definitely help me – Kritz Feb 07 '12 at 12:48
  • Although Hans' link is related, it's certainly not an **exact** duplicate... – Meta-Knight Feb 07 '12 at 13:57

1 Answers1

1

for this kind of i-don't-know-where-to-look issue, i trapped exception at application level with the Application.DispatcherUnhandledException event :

http://msdn.microsoft.com/en-us/library/system.windows.application.dispatcherunhandledexception.aspx

and then in the event handler i get the StackTrace and display it in a MessageBox / dump it in a file, along with the exception.Message.

Next i offer the user the choice to re-launch the application.

GameAlchemist
  • 18,995
  • 7
  • 36
  • 59
  • How do you relaunch the application? – Kritz Feb 13 '12 at 12:07
  • i used System.Diagnostic.Process.Start(Application.ResourceAssembly.Location). I don't know if this work with a click once application, i use standard installer. So call this right after your Application.Current.Shutdown(), which, as you may know, has not an instant effect. – GameAlchemist Feb 13 '12 at 12:30