Public Class creates System.StackOverflowException
Posted on 2004-03-26
I've created a public class with some shared properties that I'll set-up initially in my solution and then use the values in different parts of the solution.
It's possible, if the app.config file isn't set correctly that a blank value could propogate to the shared value. To prevent this, I've gone for a 'belt & braces' approach where the property has a default value, but also check the value that's sent to make sure it's not blank.
A subset of the class below;
Public Class dbInfo
Private Const dbPathDef As String = "C:\Program Files\Database"
<System.ComponentModel.Description("The directory path to the database."), _
Public Shared Property dbPath() As String
Set(ByVal Value As String)
If Len(Value) = 0 Then
dbPath = dbPathDef
dbPath = Value
Although the code compiles ok, it throws the following exception at the 'If Len(Value) = 0 Then' point
An unhandled exception of type 'System.StackOverflowException' occurred in microsoft.visualbasic.dll
I've tried other string comparison methods (Value = "", Value Is Nothing, Value <> "") but still get the same exception thrown
The exception is still produced if I remove the attribute settings.