You are visitor number ????? since February 2004.
Go to Howard Kaikow's home page


Copyright © 2004 by Howard Kaikow. All rights reserved.
Date: 22 February 2004
From: Howard Kaikow <kaikow@standards.com>
Subject: Try/Catch does not detect out of stack space error


On 14 February 2004, I posted the topic "Error handling doesn't work when I ugrade to VB .NET 2003" in the microsoft.public.dotnet.languages.vb.upgrade newsgroup.

As a result of that discussion, I have created a simplified example to demonstrate the problem in both VB.NET 2002 and VB.NET 2003.

I created the VB .NET 2003 project from a new project in VB .NET 2003.

I created the VB .NET 2002 project from the VB .NET 2003 project using the instructions in http://www.codeproject.com/KB/macros/vsconvert.aspx.

I have identified several code blocks using comments. To understand the rest of this document, you will need to download and view the code.

Running the code with VB .NET 2003, I find the following:

    ' Neither the  Try/Catch in btnStart_Click, or in TestRecursion, will detect a stack overflow
    ' error if ANY of the code blocks identified as L or Bn are uncommented, where "n" is a number
    ' from 1 to the number of code blocks identified as failing that use Rnd or Random.

    ' If code block L is not uncommented, then Try/Catch will detect a stack overflow error if any
    ' of the code blocks identified as Gm are uncommented, where "m" is a number from 1 to the
    ' number of code blocks identified as OK that use Random.

Running the code with VB .NET 2002, I get the same results with the following two differences:

  1. Using code block B3, in VB .NET 2002, Try/Catch does trap the stack overflow error. The error is not trapped by Try/Catch with VB .NET 2003.
  2. Using code block B1, in VB .NET 2003, Try/Catch fails to detect the stack overflow error. In VB .NET 2002, the behavior is worse, as no error is issued at runtime.

Downloads

Download VB .NET 2002 project.

Download VB .NET 2003 project.