dahall / AeroWizard

Library for easy creation of custom and Aero Wizards. Aero Wizard strictly follows Microsoft guidelines and uses Visual Styles to get visual theming.
MIT License
112 stars 32 forks source link

Exception when reconnecting RDP session on Windows 2003 Server #40

Closed dahall closed 5 years ago

dahall commented 5 years ago

He,

I use my Wizard also on Windows 2003 without all this nice Aero features. Everytime when I disconnect or minimize my RDP session and went back later the following exception is thrown:

t System.Drawing.Graphics.Clear(Color color)

at AeroWizard.ThemedTableLayoutPanel.OnPaint(PaintEventArgs e)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer)
   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.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)

I digged into this and trying to use this workaround the prevent the exception window:

if (!this.IsDesignMode() && SupportGlass && DesktopWindowManager.IsCompositionEnabled())           
{               
try               
{                   
e.Graphics.Clear(System.Drawing.Color.Black);               
}
catch (Exception)               
{  }
}

Are you an idea how we can prevent this error?

Thanks
Dirk

Originally posted: 2011-09-04T01:14:40

dahall commented 5 years ago

Hi,

ok I worked  a little bit on this issue and found out this is the explaination:

http://connect.microsoft.com/VisualStudio/feedback/details/323567/generic-gdi-exception-when-calling-graphics-clear-in-a-terminal-server-session

Currently it's not allowed to paint in a DC on RDP sessions or secure desktop (e.g. UAC). I wrote a short wrapper arround the direct calls with exception  handling. This works for my TS use case very well. I will add this as patch :-)

Dirk

Originally posted: 2011-09-04T02:20:15

dahall commented 5 years ago

Corrected in the 1.1 release.

Originally posted: 2011-09-08T12:05:13