Results 1 to 8 of 8

Thread: Unhandled exception in Windows Form Designer generated code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    243

    Unhandled exception in Windows Form Designer generated code

    I have 2 projects within the same solution. I can build both projects and build the solution without a problem. When I go to debug I get a:
    An unhandled exception of type 'System.StackOverflowException' occurred in GradeReport.exe

    The error takes me to the MyBase.New() line in my code. Can anyone tell me what this means or how to fix it?? Thanks

    VB Code:
    1. #Region " Windows Form Designer generated code "
    2.  
    3.     Public Sub New()
    4. ------> MyBase.New()
    5.  
    6.         'This call is required by the Windows Form Designer.
    7.         InitializeComponent()
    8.  
    9.         'Add any initialization after the InitializeComponent() call
    10.  
    11.     End Sub

  2. #2
    Frenzied Member ntg's Avatar
    Join Date
    Sep 2004
    Posts
    1,449

    Re: Unhandled exception in Windows Form Designer generated code

    This just inherits from System.Windows.Forms.Form? If so, what variables do you have declared in the form?
    "Feel the force...read the source..."
    Utilities: POPFileDebugViewProcess ExplorerWiresharkKeePassUltraVNCPic2Ascii
    .Net tools & open source: DotNetNukelog4NetCLRProfiler
    My open source projects: Thales SimulatorEFT CalculatorSystem Info ReporterVSS2SVNIBAN Functions
    Customer quote: "If the server has a RAID array, why should we bother with backups?"
    Programmer quote: "I never comment my code. Something that is hard to write should be impossible to comprehend."
    Ignorant quote: "I have no respect for universities, as they teach not practicle stuff, and charge money for"

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    243

    Re: Unhandled exception in Windows Form Designer generated code

    Just some basic stuff to load combo boxes. I have the code in classes.


    VB Code:
    1. Dim myLS As New clsLoadCombo
    2.     Dim myLV As New clsLoadListView
    3.     Dim myBQ As New clsBuildSQL
    4.  
    5.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    6.         lvwSelectedFields.Clear()
    7.         myLS.loadSortBy(cboSortBy)
    8.         myLS.loadSelectField(cboSelectField)
    9.         myLS.loadSelectView(cboSelectByValue, cboBuilding.Text)
    10.     End Sub
    11.  
    12.     Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
    13.         lvwSelectedFields.Clear()
    14.         myLS.loadSortBy(cboSortBy)
    15.         myLS.loadSelectField(cboSelectField)
    16.         myLS.loadSelectView(cboSelectByValue, cboBuilding.Text)
    17.     End Sub
    18.  
    19.     Private Sub btnPrint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPrint.Click
    20.         Dim myPR As New clsPrint
    21.         Dim report As String
    22.         Dim query As String
    23.  
    24.  
    25.         'Send report name and query to print function.
    26.         query = myBQ.BuildSql
    27.         myPR.PrintReport(report, query)
    28.     End Sub

  4. #4
    Frenzied Member
    Join Date
    Nov 2003
    Posts
    1,489

    Re: Unhandled exception in Windows Form Designer generated code

    put a break at the call to InitializeComponent() in Sub New()...follow that by using F11. You have a loop in that sub that is causing that.

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    243

    Re: Unhandled exception in Windows Form Designer generated code

    It didn't make it to the InitializeComponent(), so I put a break at the myBase.New(). It goes back and forth between the myBase.New() and my first class declaration, so I see what you are saying about the loop.

    ---> Dim myLV As New clsLoadListView
    Dim myBQ As New clsBuildSQL
    Dim myPR As New clsPrint
    Dim myLS As New clsLoadCombo

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    243

    Re: Unhandled exception in Windows Form Designer generated code

    I took out the class declarations and placed them inside each sub they are used in. Everything works fine now. But my question is, hwo can I only declare a class once and use it throughout the scope of the form in different subs?

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Unhandled exception in Windows Form Designer generated code

    Try declaring your variables at the class level but not instantiating them until the constructor or Load event handler. I think this should fix the symptoms but I'm not sure what the underlying cause would be. Perhaps there is an issue with your clsLoadListView class.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jun 2005
    Posts
    243

    Re: Unhandled exception in Windows Form Designer generated code

    I had the same feeling about the clsLoadListView class. So I commented that line out. And the same thing happens with the rest of my classes as well.
    But I will try your suggestion and get back with you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width