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
- 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 MySettingsGet#If _MyType = "WindowsForms" ThenIf Not addedHandler ThenSyncLock addedHandlerLockObjectIf Not addedHandler ThenAddHandler My.Application.Shutdown, AddressOf AutoSaveSettingsaddedHandler = TrueEnd IfEnd SyncLockEnd If#End IfReturn defaultInstanceEnd GetEnd PropertyThe 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.
답변
- 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- 답변으로 표시됨eryangMSFT, 중재자2009년 11월 10일 화요일 오전 9:27
모든 응답
- 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 - 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.
- 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- 답변으로 표시됨eryangMSFT, 중재자2009년 11월 10일 화요일 오전 9:27

