good evening!
try something like this...
i hope i can give u some idea...
game-master
Main Topics
Browse All TopicsHI All
I am writing a new application from scratch and I thought it would be nice to have my own error system. I know how to trap an error in an individual function, sub routine, etc using on error or try catch, but how can I redirect all errors trapped or otherwise.
by default errors in apps in .net are fine but are too complicated for most of my users to deal with. so what I want is to have my own form within the application that handles the error and presents it in a more user friendly way. So an error occurs and this particular form pops up. This form will then explain the error to the user and then give them the option of directly sending this error to my support desk.
All help appreciated!
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
RolandDeschain: This doesnt seem to be working how I would expect it to.
I created a form and I added a button. To that buttons click event I added the following code
Dim a() As String
a(1) = "DD"
to force an error.
I then did what you said and in that class event Iadded this code
Private Sub MyApplication_UnhandledExc
Dim oFrm As New ErrorHandler.frmMain
oFrm.Text = "tosser"
oFrm.Show()
End Sub
where ErrorHandler is a class in my application.
So in Visual studio when the eror occurs it goes back to VS and tells me a problem. I I run the software outside of visual studio and the form I specified pops up but it pops up really fast and then the whole application closes.
I want the new form to come up explaining what the error is, any ideas?
Well, this is because exiting application on unhandled exception is the normal behaviour in Windows Forms applications. To avoid this behaviour, follow this simple steps:
- First, when you show the form inside the UnhandledException event, show it modal; this will keep the form shown until the user closes it.
oFrm.ShowDialog() 'Instead oFrm.Show()
- Second, tell framework that the error should not close the application, by setting the ExitApplication property of the "e" argument.
e.ExitApplication = False
(Note: you can use the e.Exception property to know details about the error that throws the UnhandledException event, maybe presenting the info to the user).
Hope that helps.
Business Accounts
Answer for Membership
by: RolandDeschainPosted on 2009-11-06 at 02:58:29ID: 25758078
Well, there's a way to catch all the exceptions into an application (in fact, all the unhandled exceptions).
ception" creates.
Follow this steps:
- In solution explorer, right-click your project's node and click Properties. The properties window will appear.
- In properties window, click on "Application" tab if it's not the active tab.
- Bottom right in the properties tab there's a button named "View application events" (maybe that's not the exact text, as my Visual Studio is not in english). Click on it.
- A new class, "ApplicationEvents.vb", adds to your application.
- In the class name combobox (above of the code window, left side), expand combobox and select the "MyApplication events" item.
- Expand the method name combobox (above of the code window, right side) expand combobox and select the "Unhandled exception" method.
- A new Sub called "MyApplication_UnhandledEx
Inside of this sub you can write your code to handle your application errors. This sub will be called for ALL the errors of your application (well, all of them that are not handled by it's onw Try..Catch or OnError instructions) anywhere in your app.
Hope that helps.