문제

몇 시간 동안 응용 프로그램을 사용한 후에 매일 아래 오류와 호출 스택이 동시에 발생합니다.무슨 일이 일어나고 있는지 알려줄 수 있는 사람이 있나요?

System.InvalidOperationException: BufferedGraphicsContext cannot be disposed of because a buffer operation is currently in progress.

at System.Drawing.BufferedGraphicsContext.Dispose(Boolean disposing)

at System.Drawing.BufferedGraphicsContext.Dispose()

at System.Drawing.BufferedGraphicsContext.AllocBufferInTempManager(Graphics targetGraphics, IntPtr targetDC, Rectangle targetRectangle)

at System.Drawing.BufferedGraphicsContext.Allocate(IntPtr targetDC, Rectangle targetRectangle)

at System.Windows.Forms.Control.WmPaint(Message& m)

at System.Windows.Forms.Control.WndProc(Message& m)

at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

at System.Windows.Forms.ToolStrip.WndProc(Message& m)

at System.Windows.Forms.MenuStrip.WndProc(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
도움이 되었습니까?

해결책

이 오류에 대한 매우 긴 MSDN 포럼 토론이 있습니다. 여기.대부분의 경우 오류는 다음 중 하나와 연관되어 있는 것으로 보입니다.

  1. 프레임워크 버그로 인해 BufferedGraphicsContext 예외로 나타나는 기본 OutOfMemory 문제입니다.
  2. GDI 개체 누출(GDI 개체를 생성하고 삭제하지 않음)

나는 약 1년 전에 이 오류를 직접 본 것을 기억하며, 이는 확실히 우리 앱이 장기적으로 사용 가능한 모든 VM을 채우게 만드는 메모리 문제와 관련이 있으므로 #1은 내가 관찰한 내용에 동의합니다.

다른 팁

나는 이 질문이 오래되었다는 것을 알고 있지만 동일한 문제가 있었고 수동 이중 버퍼링을 구현하는 여러 컨트롤을 사용할 때만 나타나는 것을 발견했습니다.

나로서는 이 시점에서 문제를 발견했다.

BufferedGraphicsContext _BackbufferContext = BufferedGraphicsManager.Current;

그래서 내 모든 컨트롤은 현재의 나는 항상 동일하다고 가정합니다.내가 그것을 교체 한 후

BufferedGraphicsContext _BackbufferContext = new BufferedGraphicsContext();

모든 것이 원하는 대로 작동합니다.

이것이 조금 도움이 되었기를 바랍니다.

어둠 속에서 찍은 사진 - 여러 개의 스레드로 그림을 그리는 중인가요?페인팅 관련 작업을 수행하는 경우 GUI 스레드에서 수행하거나 코드를 주의 깊게 동기화하십시오.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top