2
Answers

Closing Application on Error

dferguson32

dferguson32

21y
2.3k
1
In the constructor of my initial windows form class I would like to do some set up of various parameters. If errors occur during this setup I would like an error message to appear and the entire application to end. Unfortunately, the initial form appears and must be closed. I have tried adding a close() in the constructor but probably because the form has not been shown at this point this doesn't work. Some code snippets are as follows. Any ideas? TIA static void Main() { Application.Run(new Master()); } public class Master : System.Windows.Forms.Form { InitializeComponent(); // test new data Access class try { da = new DataAccess(); } catch (Exception err) { MessageBox.Show(err.ToString()); Close(); // note: doesn't work return; // returns but form is still displayed } ..... }
Answers (2)
0
CScorner
NA 11 0 21y
Hello, I have found a very good german site, I don't know it helps you? http://www.golohaas.de/csharp/index.php There you can find a lot af tipps to use. regards, ralf
0
sgreenst
NA 10 0 21y
I found a couple of used C# programming books from O'Reilly (good ones) used on Amazon for $8 each.
0
Ben
NA 159 0 21y
I would very much recommend Microsoft C# Programming for the Absolute Beginner, by Andy Harris ($30.00 at Amazon or Borders). It teaches you the basics of C# through simple games, which, fun as they are, really do get the point across. At the end of each chapter you are given some ways to improve or change the game that you worked on in that chapter, which stretches your thinking a bit. I hope this helps : )
0
ssswamii
NA 180 0 21y
Your most useful source is at msdn.microsoft.com/vcsharp. MSDN documentation is also built into Visual Studio for offline access as an easy, quick reference. These 2 sources will help you overcome most issues by your own discovery, which is a helluva lot better than someone else telling you how to do it. Your second most useful source is forums like these, IMO. c-sharpcorner.com, csharphelp.com, dotnet247.com, dotnetjunkies.com, thecodeproject.com, all have decent communities that are willing to help you if you've got a problem. thecodeproject.com I'd say has the best community of them all. Books are good once you've had experience. IME, books seem too difficult to grasp if it's discussing a topic in which you've never written code before. I prefer the MSDN & .Net communities route, but that's just me. :)
0
fubak1
NA 2 0 21y
I am just learning C# also. I haven't gotten very far, but here are some good resources... Books: C#: A Beginner's Guide by Herb Schildt Websites: www.devasp.net www.thecodeproject.com www.c-sharpcorner.com - duh