Click here to Skip to main content
15,913,773 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to use Raster/Bitmap Fonts ... ? Pin
Karl 200029-Jun-04 3:54
Karl 200029-Jun-04 3:54 
GeneralExporting toCSV Pin
Member 120485128-Jun-04 12:03
Member 120485128-Jun-04 12:03 
GeneralRe: Exporting toCSV Pin
Dave Kreskowiak29-Jun-04 3:43
mveDave Kreskowiak29-Jun-04 3:43 
GeneralRe: Exporting toCSV Pin
Member 120485129-Jun-04 10:50
Member 120485129-Jun-04 10:50 
GeneralRe: Exporting toCSV Pin
Heath Stewart29-Jun-04 3:58
protectorHeath Stewart29-Jun-04 3:58 
GeneralRe: Exporting toCSV Pin
Member 120485129-Jun-04 10:53
Member 120485129-Jun-04 10:53 
GeneralRe: Exporting toCSV Pin
Heath Stewart29-Jun-04 11:10
protectorHeath Stewart29-Jun-04 11:10 
GeneralExceptional Exceptions Pin
inyoursadachine28-Jun-04 11:56
inyoursadachine28-Jun-04 11:56 
Hi,
My understanding of the way exception work in .NET is that once an exception is thrown, the run-time unwinds the call stack until either

(a) the call stack is empty (game over) or...
(b) a catch block is found that "handles" the thrown exception

I tested this my understanding of this with the program below.
And just as I thought it would, after level5() through the exception the Runtime unwound the call stack back to level1().
My understanding is that the objectless "catch" will catch -ALL- exceptions. Period. Even unmanaged exception one of my books says.

So... if I define my static Main() as:

static void Main()
{
try
{
Application.Run(new Form1());
}
catch
{
MessageBox.Show("Not so fast!");
}
}

... is it possible for an (some) execptions to "leak" out to the Runtime?

Thanks,
Cunfewsdish

===============================================================



using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace Exceptional.cs
{
///
/// Summary description for Form1.
///

public class Form1 : System.Windows.Forms.Form
{
///
/// Required designer variable.
///

private System.ComponentModel.Container components = null;

public Form1()
{
//
// Required for Windows Form Designer support
//
InitializeComponent();

//
// TODO: Add any constructor code after InitializeComponent call
//
level1();
}

///
/// Clean up any resources being used.
///

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.Size = new System.Drawing.Size(300,300);
this.Text = "Form1";
}
#endregion

///
/// The main entry point for the application.
///

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void level1()
{
try
{
level2();
}
catch
{
MessageBox.Show("Kawt!", "Level 1");
}
}

private void level2()
{
try
{
level3();
}
catch(System.ApplicationException se)
{
MessageBox.Show("Caught!", "Level 2");
}
}

private void level3()
{
level4();
}

private void level4()
{
level5();
}

private void level5()
{
throw new System.Exception("Error!");
}




}
}
GeneralRe: Exceptional Exceptions Pin
Dave Kreskowiak29-Jun-04 3:36
mveDave Kreskowiak29-Jun-04 3:36 
GeneralRe: Exceptional Exceptions Pin
inyoursadachine29-Jun-04 5:56
inyoursadachine29-Jun-04 5:56 
GeneralRe: Exceptional Exceptions Pin
Dave Kreskowiak29-Jun-04 15:44
mveDave Kreskowiak29-Jun-04 15:44 
GeneralExecuting other applications inside another Pin
Anonymous28-Jun-04 9:12
Anonymous28-Jun-04 9:12 
GeneralRe: Executing other applications inside another Pin
Heath Stewart28-Jun-04 9:36
protectorHeath Stewart28-Jun-04 9:36 
GeneralRe: Executing other applications inside another Pin
Anonymous29-Jun-04 5:36
Anonymous29-Jun-04 5:36 
GeneralRe: Executing other applications inside another Pin
Heath Stewart29-Jun-04 5:42
protectorHeath Stewart29-Jun-04 5:42 
GeneralRe: Executing other applications inside another Pin
Anonymous29-Jun-04 6:26
Anonymous29-Jun-04 6:26 
GeneralRe: Executing other applications inside another Pin
Heath Stewart29-Jun-04 8:43
protectorHeath Stewart29-Jun-04 8:43 
GeneralRe: Executing other applications inside another Pin
Anonymous30-Jun-04 2:28
Anonymous30-Jun-04 2:28 
GeneralRe: Executing other applications inside another Pin
Heath Stewart30-Jun-04 2:38
protectorHeath Stewart30-Jun-04 2:38 
GeneralRe: Executing other applications inside another Pin
Anonymous30-Jun-04 5:47
Anonymous30-Jun-04 5:47 
GeneralRe: Executing other applications inside another Pin
Anonymous30-Jun-04 9:50
Anonymous30-Jun-04 9:50 
GeneralHaving trouble with debugging Pin
Flack28-Jun-04 9:06
Flack28-Jun-04 9:06 
GeneralRe: Having trouble with debugging Pin
Dave Kreskowiak29-Jun-04 3:24
mveDave Kreskowiak29-Jun-04 3:24 
GeneralKeeping the record on hold Pin
IamADotNetGuy28-Jun-04 8:03
IamADotNetGuy28-Jun-04 8:03 
GeneralRe: Keeping the record on hold Pin
Heath Stewart28-Jun-04 9:07
protectorHeath Stewart28-Jun-04 9:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.