473,383 Members | 1,805 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Closing an application when catching a fatal error

Hi,

I've a form.load event that initializes a cardreader, which is crucial to
the operating of the program.
Now if that throws an exception, the program needs to give a message and
close down.
I tried using Application.Exit(), but that happily executes the rest of the
code (initializing a browser component and adding some images to buttons).
Does anyone have any idea on how to make the program *really* shutdown
without running anything more ? Except maybe form.closing, that could come
in handy too :)
Nov 20 '05 #1
2 1321
Hi,

Initialize your cardreader in a sub main(in module). If cardreader
doesnt throw an exception show the Form. Of course make sub main your
startup object.

Public sub Main

Try
'Initialize CardReader Here
Dim frm as new Form1

Application.Run(frm)
Catch ex as exception
Messagebox.Show("An Error has Occurred")
end try
end sub

Ken
----------------------------
"Silby" <Si***@nothanks.net> wrote in message
news:ek********************@phobos.telenet-ops.be...
Hi,

I've a form.load event that initializes a cardreader, which is crucial to
the operating of the program.
Now if that throws an exception, the program needs to give a message and
close down.
I tried using Application.Exit(), but that happily executes the rest of the code (initializing a browser component and adding some images to buttons).
Does anyone have any idea on how to make the program *really* shutdown
without running anything more ? Except maybe form.closing, that could come
in handy too :)

Nov 20 '05 #2
Ahh, excellent.
Thanks for the tip !

"Ken Tucker [MVP]" <vb***@bellsouth.net> wrote in message
news:ew**************@TK2MSFTNGP10.phx.gbl...
Hi,

Initialize your cardreader in a sub main(in module). If cardreader doesnt throw an exception show the Form. Of course make sub main your
startup object.

Public sub Main

Try
'Initialize CardReader Here
Dim frm as new Form1

Application.Run(frm)
Catch ex as exception
Messagebox.Show("An Error has Occurred")
end try
end sub

Ken
----------------------------
"Silby" <Si***@nothanks.net> wrote in message
news:ek********************@phobos.telenet-ops.be...
Hi,

I've a form.load event that initializes a cardreader, which is crucial to the operating of the program.
Now if that throws an exception, the program needs to give a message and
close down.
I tried using Application.Exit(), but that happily executes the rest of

the
code (initializing a browser component and adding some images to buttons). Does anyone have any idea on how to make the program *really* shutdown
without running anything more ? Except maybe form.closing, that could come in handy too :)


Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Alexey Kouzmitch | last post by:
Hi, I wrote a console application which is called from a SQL Server job. The application utilizes a COM object, to pump data from a legacy (not very old however) application to SQL server. The...
1
by: ds | last post by:
fatal error C1189: #error : WINDOWS.H already included. MFC apps must not #include <windows.h> I have an existing C-based application. I need to add encoder card support to this application....
5
by: Ron L | last post by:
I have an MDI application with a number of child windows. In each child window I am catching the Closing event and having the child window decide if it should set cancel to true. The intent here...
5
by: Jason MacKenzie | last post by:
I have a production critical windows forms application. I have try catch blocks everywhere to handle every eventuality. However occasionally, every couple of months, the application crashes. Its...
10
by: Charles Law | last post by:
For some reason, when I click the X to close my MDI parent form, the action appears to be re-directed to one of the MDI child forms, and the parent remains open. I am then unable to close the...
11
by: Dursun | last post by:
I need to make sure that the user cannot close (using "X") the form before saving the data on it. Which form event should I write the control code in? Thank you, -Delen
10
by: John Kraft | last post by:
Hello all, I'm experiencing some, imo, strange behavior with the StreamReader object I am using in the code below. Summary is that I am downloading a file from a website and saving it to disk...
4
by: dave m | last post by:
I'm creating a class library (dll) and am confused as how to pass any information, should any exceptions occur, back to the calling application. Such as: Try x = 3 / 0 ' divide by 0 error...
14
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using VS2005 and .net 2.0. I'm creating an application that has 3 forms. I want allow users to move forward and backward with the forms and retain the data users have entered. I thought...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.