This project has moved. For the latest updates, please go here.

Exception when reconnecting RDP session on Windows 2003 Server

Sep 4, 2011 at 7:14 AM

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

Sep 4, 2011 at 8:20 AM

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

Coordinator
Sep 8, 2011 at 6:05 PM

Corrected in the 1.1 release.