Don't know if this is right group to post this question.
My program is in .Net 2.0,
It is data entry form that has no code related to graphic manupilation. But my clients sometimes get this error. and it will show some big red X over some controls.
I've never seen it in my development machine though.
"BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress."
What could cause this problem
Thanks

BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress.
noname00
This generally happens when a BufferedGraphicsContext is disposed without been invalidated it. It looks like this app is using double-buffering, is it handling a previous exception that would let the BufferedGraphicsContext hanging around
Pepp
I have the same problem. First i didn't use double buffering. I have an application that displays big images : 1536 x 1200
Then when i got this error, i made some researches so i endup up to using double buffering. Then it reduces the number of erros (crashes with the same message : buffered graphics cannot be disposed...). It displays this error once an hour....
It doesn't make this erro on xp, only on win98. THe memory isn't the problem, i have 512 Mo ram. When i had only 256 Mo, it makes this error more often.
I'm gonna try to invalidate the graphics before disposing...
Chris Breaux
Be sure to create and show forms only on the UI thread.
BQMartin
cworkman29729
I have exactly the same problem as the previous author - has no-one found a solution
I simply use this.DoubleBuffered = true and then draw away. It never happens on the development machines and generally happens on test computers with quite low system specifications.
Skyruner2
StuartF
I am a developer of .NET components. I have recently received a report with the same exception from one of our customers. Have anybody found a solution to this. I do not use anything related to the BufferedGraphicsContext class except for the built-in double buffering:
SetStyle(ControlStyles.DoubleBuffer, true);
It looks like a bug in .NET 2.0. Any suggestions
JRusty
We've now seen this with two customers in the field, both on Windows 98 machines. I don't believe the OS is necessarily the problem, but the low end hardware probably has someting to do with it! We're not doing any custom painting using double-buffering ourselves, but we use a number of components (Infragistics, DotNetBar) that certainly do.
If anyone has any information, it would be extremely helpful and appreciated.
Brett H.
I've got the same exception.
Details:
Message "BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress." string
StackTrace " at System.Drawing.BufferedGraphicsContext.Dispose(Boolean disposing)" string
I'm using DoubleBuffered control style as following:
Me.SetStyle( _ControlStyles.UserPaint _
Or ControlStyles.DoubleBuffer _ Or ControlStyles.AllPaintingInWmPaint, _ True))Any ideas why
PareshPatel
confuced!
I get the following exception when showing and then removing a user control lots of times:
00117528 00:55:06 [7452] MyApplication_UnhandledException @ 15/07/2007 00:55:05
00117529 00:55:06 [7452] System.InvalidOperationException
00117530 00:55:06 [7452] BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress.
00117531 00:55:06 [7452] at System.Drawing.BufferedGraphicsContext.Dispose(Boolean disposing)
00117532 00:55:06 [7452] at System.Drawing.BufferedGraphicsContext.Dispose()
00117533 00:55:06 [7452] at System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)
00117534 00:55:06 [7452] at System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC, Rectangle targetRectangle)
00117535 00:55:06 [7452] at System.Windows.Forms.Control.WmPaint(Message& m)
00117536 00:55:06 [7452] at System.Windows.Forms.Control.WndProc(Message& m)
00117537 00:55:06 [7452] at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
00117538 00:55:06 [7452] at DevComponents.DotNetBar.PanelEx.WndProc(Message& m)
00117539 00:55:06 [7452] at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
00117540 00:55:06 [7452] at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
00117541 00:55:06 [7452] at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
I have a DotNetBar PanelEx on the user control. I also feel this could be associated with memory issues as my app was using 1.5GB after running over the weekend and then showing this message towards the end of the test.
Regards, Carl Gilbert
BrammekeDotNet
Rafael Nami
i do have faced same type of isssue, firstly on deployment machines but now on development machine as well, i do have 2GB of ram so its not the issue with ram but i have reached to the conclusion that if the process is in paint method, and we call the paint again then this error will come see the code below
pictureBox1.Invalidate();
pictureBox1.Update();
do write the code in paint method of the picture box i-e calling the repaint in paint.
Poney
My boss asked me to resolve it but it seems that it's a bug of .net framework.
I am wondering if I could re-compile my program on .Net 3.0 to resolve it.