C# StackOverFlowException when creating new instance of class

Hm i get a strange problem. when i creating new instance of class i get StackOverflowExcepion :)

Here is code:

public partial class PlayerChooser : Window
{
public PlayerChooser()
    {
        InitializeComponent();
        textBoxPlayer1Name.Visibility = Visibility.Hidden;
        textBoxPlayer2Name.Visibility = Visibility.Hidden;
        textBoxPlayer3Name.Visibility = Visibility.Hidden;
        textBoxPlayer4Name.Visibility = Visibility.Hidden;

    }

    public static String player1Name;
    public static String player2Name;
    public static String player3Name;
    public static String player4Name;
    ...

    PlayerChooser.player1Name = textBoxPlayer1Name.Text;
    PlayerChooser.player2Name = textBoxPlayer2Name.Text;
    TwoPlayers501_new twoPlayers501_new = new TwoPlayers501_new();
    twoPlayers501_new.Show();
    ...
}

and class and constructor where exception occurs

public partial class TwoPlayers501_new : Window
{
    public TwoPlayers501_new()
    {
        InitializeComponent();

        textBlockPlayer1Name.Text = PlayerChooser.player1Name;
        textBlockPlayer2Name.Text = PlayerChooser.player2Name;
    }
    ...
}

thanx in advance, it is probably some kind of triviality...

Answers


Do you have an event handler somewhere performing an action that changes one of those properties based on the property having been changed?

Short version: There isn't enough information here to debug your problem.

Suggestion: Debug your program and when you get the stackoverflowexception, check out the callstack. I suspect that there's a method or series of methods that cycle infinitely in your stack.


Need Your Help

Drag and Drop between xtragrid and Scheduler

c# .net winforms devexpress

someone can tell me how to drag and drop data between gridcontrol and schedulercontrol from devexpress? I want to drag the data from the grid and drop it on the scheduler. The devexpress example in...

Modelling Parent-Child Relationships with Classes

c# design

I am working on a lightweight document management system and am looking for some help with how best to model certain relationships. Essentially, I am working with two "organizational units": Group...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.