Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6469039
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T05:56:48+00:00 2026-05-25T05:56:48+00:00

I have a winform application. Every few seconds I check some log files, read

  • 0

I have a winform application. Every few seconds I check some log files, read in any new data and insert any new data into a DB.

When I run the application for around an hour 1/2, I get a StackOverflowException. There was no new data in the log files for that entire period, so nothing new was added to the DB.

The code errored here…

if (pictureBox == null)
{
    continue;
}

if (pictureBox.InvokeRequired)
{
    var toolTip = new ToolTip();
    GameServer tempGameFile = gameServer;
    pictureBox.Invoke(new MethodInvoker(
        () => toolTip.SetToolTip(pictureBox,
            string.Format(
                "{0} : Last Checked: {1}; Last Updated: {2}",
                tempGameFile.Name,
                tempGameFile.CheckedOn.ToLongTimeString(),
                tempGameFile.UpdatedOn.HasValue
                    ?
                        tempGameFile.UpdatedOn.Value.ToLongTimeString()
                        : "-No Date Set-"))));
}
pictureBox.Image = Resources.RedButton;

and the pictureBox.Invoke(..) is throwing that error.

So .. i’m not sure how I can bebug this to figure out what is going on? Any suggestions?

UPDATE

Trying the suggestions of Dmitry I’ve started an ANTS profiler memory profile .. and having a quick look at things .. there seems to be a lot of instances of ToolTip controls.

This is a class list summary after 20 mins.

enter image description here

Lots of EventHandlers (am I not releasing something?)

And there’s a few ToolTips also…

Here is a screenshot of all the instances and here is a screenshot of a single ToolTip control graph/map .. which I don’t know how to read blush

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T05:56:48+00:00Added an answer on May 25, 2026 at 5:56 am

    You have 2 potential issues with your code:

    var toolTip = new ToolTip();

    and

    pictureBox.Image = Resources.RedButton;

    are both called on non-UI thread. I have to marshal this code to UI thread using Control.Invoke. If fixing this does not help, look at my answer on how to debug StackOverflowException in windows service.

    UPDATE: try this code. Note that every statement that references any UI control needs to be marshaled using Control.Invoke:

    if (pictureBox == null || !pictureBox.IsHandleCreated) {
        continue;
    }
    
    Action setTooltipAndImage = () => {
        var toolTip = new ToolTip();
        GameServer tempGameFile = gameServer;
        toolTip.SetToolTip(pictureBox, string.Format(...));
        pictureBox.Image = Resources.RedButton;
    };
    
    if (pictureBox.InvokeRequired) {                        
        pictureBox.Invoke(setTooltipAndImage);
    } else {
        setTooltipAndImage();
    }
    

    It might worth reading Manipulating Controls from Threads.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a winforms application calling a stored procedure every few seconds. The stored
I have a winform application that uses some referenced web services to get data.
I have to read a binary file data into a C# winform application. The
I have my winform application gathering data using databinding. Everything looks fine except that
I am trying to implemented F1 help for my WinForm application. I have read
i have to capture screenshot of Desktop after every one second. in Winform application
I have a WinForm application which is generating CSV files. I give the user
I have a winform application and a list of logins to some web-service. Upon
I have a Winform application built with C# and .Net 2.0. I have a
I have a WinForm application built with VS 2008 (C#) and SQL Server Express

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.