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 6096975
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T12:59:23+00:00 2026-05-23T12:59:23+00:00

I have an odd problem when my app is running and the system resumes

  • 0

I have an odd problem when my app is running and the system resumes from hibernation (in Windows 7).

I am calling the Graphics.DrawString method and this works fine most of the time. Except when the program is running and I hibernate the system. Then when I resume, the DrawString method throws an ArgumentException (Parameter is not valid) and gives me a red cross where my drawing should be.

What is going wrong here? Catching the exception avoids the red cross but when we get into this state there is no way back and the exception will keep being thrown until the program is restarted.

Thanks for any help,
Alan

Edit: Here is the code that is failing:

protected override void OnPaint(PaintEventArgs e)
{
    // Drawing logic succeeds until this point

    e.Graphics.DrawString(Text, Font, new SolidBrush(ForeColor), new PointF(x, y));
}

This is actually a subclass of ToolStripLabel.

  • 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-23T12:59:23+00:00Added an answer on May 23, 2026 at 12:59 pm

    Many system resources become invalid after a sleep or hibernation. So your Font is probably invalid as that is a common cause of such issues. Also I note that you are not calling Dispose on the SolidBrush which you should do that to prevent resource leeks. Like this…

    using(SolidBrush drawBrush = new SolidBrush(ForeColor))
        e.Graphics.DrawString(Text, Font, drawBrush, new PointF(x, y));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an odd problem in VS2008 running unit tests. When I run the
I have an odd problem where Hibernate is running more queries than I've asked
I have an odd problem that is crashing my app, that I would like
So this is a fairly odd problem: I am currently working on an app
I have an odd problem. I'm trying to echo the response from a file
I have run into a rather odd problem, my app crashes if I try
hopefully someone can help me with this odd problem. I have a database which
I have an odd problem...I'm using a documentation generator which generates a lot of
I have the odd problem that I am not able to open the properties
I have an odd problem with Django. I have a set of objects that

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.