I get a stackoverflow exception on following commented line.

namespace Football_Manager_WFA
{    
    public partial class Settings : Form
    {
        Color def_bgdColor = SystemColors.Control;
        Color def_fontColor = Color.Black; // ERROR
        static FontFamily fontFamily = FontFamily.GenericSansSerif;
        Font def_fontType = new Font(fontFamily, 8.0f);
    }
}

Recommended Answers

All 2 Replies

A StackOverflowException is usually caused by recursive function calls. Try taking a look at the method(s) that instantiate a new instance of the Settings class (or post them here). There is probably something that calls the method again, or another method that ends up calling the method.

If your IDE shows gives you a call stack, post that too. I'm pretty sure Visual Studio won't, and since .NET 2.0, you can't catch it.

Thanks. The problem was as you said nmaillet.

I initialized Settings form two times, so just deleted one of them, and it works now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.