I have an application that is going into an apparent infinite loop while setting up Settings, before the main window even loads.
The error occurs in the Default method of MySettings, on the AddHandler statement.
Public Shared ReadOnly Property [Default]() As MySettings
Get
#If _MyType = "WindowsForms" Then
If Not addedHandler Then
SyncLock addedHandlerLockObject
If Not addedHandler Then
AddHandler My.Application.Shutdown, AddressOf AutoSaveSettings
addedHandler = True
End If
End SyncLock
End If
#End If
Return defaultInstance
End Get
End Property
The exception thrown is StackOverflowException, which clearly points to an infinite loop.
What is causing this? This is in Visual Studio 2008 Express, using .Net 3.5.