Microsoft Developer Network > 포럼 홈 > .NET Base Class Library > Stack overflow from apparent infinite loop in Settings.Designer.vb
질문하기질문하기
 

답변됨Stack overflow from apparent infinite loop in Settings.Designer.vb

  • 2009년 11월 4일 수요일 오후 6:10bienvenunet 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    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. I have not modified the above code nor do I intend to.

답변

모든 응답

  • 2009년 11월 4일 수요일 오후 6:28Reed Copsey, Jr. 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    I'd guess that this isn't the actual problematic line, but rather the line where you overflow your stack.

    Try opening up the call stack window in the debugger when this occurs, and seeing what is accessing MySettings.  My guess is that you're trying to access your settings for a property initialization routine somewhere, but calling it incorrectly, and causing the infinite loop.
    Reed Copsey, Jr. - http://reedcopsey.com
  • 2009년 11월 5일 목요일 오전 12:51bienvenunet 사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     
    The call stack isn't helpful. I put a breakpoint on the bolded line and the first time it breaks, the only thing under the Default property in the stack is External Code.
  • 2009년 11월 5일 목요일 오전 5:24MSFT Johan Stenberg중재자사용자 메달사용자 메달사용자 메달사용자 메달사용자 메달
     답변됨
    From http://msdn.microsoft.com/en-us/library/a3694ts5.aspx:

     To display non-user code frames in the Call Stack window

       Right-click the Call Stack window and choose Show External Code

    This will hopefully give you a better idea as to what is going on...

    Best regards,
    Johan Stenberg


    Microsoft Visual Studio