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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:17:58+00:00 2026-06-04T20:17:58+00:00

For some reason we are getting InvalidOperationException: Object is currently in use elsewhere. during

  • 0

For some reason we are getting “InvalidOperationException: Object is currently in use elsewhere.”

during our custom OnPaint, below (that’s actually almost a line for line copy of the code… there’s that little there).

We have logging in the exception handler below to detect if we’re somehow calling OnPaint from a non-UI thread… and that isn’t getting tripped, but we are getting that error logged (see stack trace below).

On machines where we’re getting these errors, we’re also seeing the dreaded Red X of doom from other controls (which presumably don’t have a try/catch around their OnPaints).

They’re probably related, but I can’t figure out what could be causing that error if this code is only called from the UI thread.

Any ideas?

This is the stack trace:

System.InvalidOperationException: Object is currently in use
elsewhere.
at System.Drawing.Graphics.CheckErrorStatus(Int32
status)
at System.Drawing.Graphics.DrawRectangle(Pen pen, Int32
x, Int32 y, Int32 width, Int32 height)
at
System.Windows.Forms.ControlPaint.DrawBorderSimple(Graphics graphics,
Rectangle bounds, Color color, ButtonBorderStyle style)
at
System.Windows.Forms.ControlPaint.DrawBorder(Graphics graphics,
Rectangle bounds, Color color, ButtonBorderStyle style)
at
MyUserControl.OnPaint(PaintEventArgs e)

This is the class:

public class MyUserControl : UserControl
{
    // Override this to set your custom border color
    protected Color mBorderColor = SystemColors.ControlDarkDark;

    public MyeUserControl()
        : base()
    {
        this.BorderStyle = BorderStyle.None;
        this.Padding = new Padding(1);
    }

    protected override void OnPaint(PaintEventArgs e)
    {
        base.OnPaint(e);
        try
        {
            ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, mBorderColor, ButtonBorderStyle.Solid);
        }
        catch (Exception ex)
        {
            // check if we're not on the UI thread, and if not, log it
            // log exception
        }
    }
}
  • 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-06-04T20:17:59+00:00Added an answer on June 4, 2026 at 8:17 pm

    So, I figured this out some time ago, but forgot to put the answer on here. All the customers with the problem had a single thing in common – they had installed an adobe plugin called FileOpen. It allows users to read encrypted PDFs. Turns out something FileOpen was doing (presumably to block screen captures of encrypted PDFs or something) was interfering with our application, by throwing exceptions during windows GDI+ calls (which get called from .Net OnPaint methods). In working with FileOpen, they whitelisted our application so that they wouldn’t block GDI+ calls from our application.

    What made this even more tricky to figure out, is that the blocking only happens after the first time you view an encrypted PDF using FileOpen… so you can have it installed and not experience the problem. If you stop their windows service FileOpenBroker, it also fixes the problem (presumably the service is what is doing the blocking).

    Just posting this on here in case anyone else sees the same problem, since this was a huge headache for us at work, and took weeks to figure out.

    Update:
    There’s a pretty easy workaround, which is to stop FileOpen’s service, which is called FileOpenBroker. You should be able to find it in the list of windows services and as a process in the windows task manager. Once the process has been stopped, it stops whatever they’re doing to screw up GDI+, and then you should be able to use your program until the next time you open an encrypted PDF.

    It’s been a while, so I don’t remember for sure, but it’s possible a reboot was necessary to release whatever locks they put in GDI+. I remember I built a batch file to start and stop the service, so that you could use your program without completely disabling the ability to use FileOpen (which I presume is installed because it’s in use on that computer).

    I just got contacted by someone else hitting this same problem, so it seems like FileOpen hasn’t fixed the root problem – they only put a band-aid on it by whitelisting our particular application… fair warning.

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

Sidebar

Related Questions

For some reason i'm getting an unexpected [ in the below line of code.
For some reason I keep getting a error that says toupper cannot be used
I'm trying to use MapClassLoader in autoload.php but for some reason I keep getting
For some reason nothing is getting stored in my groups_user table below is the
For some reason I'm getting a module object is not callable error on this
This is the json object: {Packet:{Response:Handshake,Code:lmhn,UID:4e1d137caaed7}} For some reason I am getting a syntax
For some reason I'm getting the error that More than one value for the
For some reason i am getting an object refrence not set to an instance
I am trying to deserialize an nhibernate object. From some reason I am getting
I'm trying to learn how to use JoGL, and for some reason I'm getting

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.