Solved

Why is this website throwing StackOverflow exception

Posted on 2013-06-13
10
362 Views
Last Modified: 2013-06-15
Hello,
I am creating instances of objects within my website so I can use them. Why is this throwing stackoverflow. Here is a mockup of the partical classes and classes. Error is firing in MSF_Methods class on the "private SessionVariables sv = new SessionVariables()"

website root partial class Default.aspx code behind:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using UserSession;
using MySchoolFeesMethods;
public partial class _Default : System.Web.UI.Page
{
    private SessionVariables sv = new SessionVariables();
    private MSF_Methods MSF = new MSF_Methods();
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}

Open in new window




these four classes are in app_code folder
using System;
using MySchoolFeesStrings;
using MsfSisMethods;
using UserSession;

namespace MySchoolFeesMethods
{
    public class MSF_Methods
    {
        private SessionVariables sv = new SessionVariables(); // Overflow on this line
        private MSF_Strings STG = new MSF_Strings();
        private MSF_SIS SIS = new MSF_SIS();
    }
    // End Namespace Block
}

Open in new window




using System;
using System.Linq;
using UserSession;
using MySchoolFeesMethods;
using MySchoolFeesStrings;


/// <summary>
/// Summary description for MSF_SIS
/// </summary>
/// 
namespace MsfSisMethods
{
    public class MSF_SIS
    {
        private SessionVariables sv = new SessionVariables();
        private MSF_Methods MSF = new MSF_Methods();
        private MSF_Strings STG = new MSF_Strings();
    }
}

Open in new window




using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using UserSession;
using MySchoolFeesMethods;

/// <summary>
/// Summary description for MSF_Strings
/// </summary>
/// 
/// 
namespace MySchoolFeesStrings
{
    public class MSF_Strings
    {
    }
}

Open in new window




using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using MySchoolFeesMethods;
using System.Collections;
using MySchoolFeesStrings;

namespace UserSession
{

    /// <summary>
    /// Summary description for clsSessionVariables.
    /// </summary>
    public class SessionVariables
    {
    }
}

Open in new window

0
Comment
Question by:tatton777
  • 5
  • 4
10 Comments
 
LVL 52

Expert Comment

by:Julian Hansen
ID: 39246829
Is this exactly how your code looks or have you just provided a skeleton?

Is there any code defined in
public class SessionVariables
{
}

Open in new window

?
0
 
LVL 1

Author Comment

by:tatton777
ID: 39248861
This is just a skeleton but it produces the same error. I tried to attach a .zip of the website the code above but zip was rejected by experts-exchange.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39249022
You have to remove the bin and obj folders as well as any *.settings files and the project should upload fine. Alternatively, you might try using www.ee-stuff.com to upload the file. It's not hosted by EE, but it is affiliated, in a roundabout way (not officially).
0
 
LVL 1

Author Comment

by:tatton777
ID: 39249036
Thanks. Here is the website that contains a skeleton of that reproduces the error.
stckOverflowMockup.zip
0
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39249072
Your problem is here:

MSF_Methods
public class MSF_Methods
{
    private SessionVariables sv = new SessionVariables();
    private MSF_Strings STG = new MSF_Strings();
    private MSF_SIS SIS = new MSF_SIS();
}

Open in new window


MSF_SIS
public class MSF_SIS
{
    private SessionVariables sv = new SessionVariables();
    private MSF_Methods MSF = new MSF_Methods();
    private MSF_Strings STG = new MSF_Strings();
}

Open in new window


Each class creates an instance of the other. You need to refactor.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 1

Author Comment

by:tatton777
ID: 39249242
Sorry to be dumb. This is the first time I've experienced this. Can you give an example.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39249348
I don't have any clue as to what you're trying to achieve with your code. What is your "business" purpose here?
0
 
LVL 1

Author Closing Comment

by:tatton777
ID: 39249383
I have a foundational misunderstanding uf classes and namespaces. This helped me understand where the softness in my thinking is. Now I just need to do some reading and researching.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39249407
I hope I didn't run you off with my previous comment. It wasn't intended to sound off-putting. I only intended to convey that it would be difficult for me to tell you how to adjust the code without knowing what your goal is. The short answer to your question is to either remove:

private MSF_SIS SIS = new MSF_SIS();
...from MSF_Methods *or* remove:

private MSF_Methods MSF = new MSF_Methods();

...from MSF_SIS, either of which may break your design. It depends on what you are trying to accomplish  = )
0
 
LVL 1

Author Comment

by:tatton777
ID: 39250273
Thanks. After doing some reading on organizing classes and namespaces and folders I am seeing that I have some restructuring to do. Thanks for your help! Take care.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Scheduled IIS .Net2 AppPools recycle and SQL connection Hangs 33 91
Problem to error 4 45
Wav problem 4 16
ASP.NET gridview select textbox on focus 2 0
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now