2

I wrote a program using c# with form application, using clipboard and capture screen. This program running remote desktop (mstsc). But if I close remote desktop window (not disconnect only close window or minimize window) my program is stopping.

I didn't find any solution. Can you help me please

Error:stack trac location: System.Drawing.Graphics.CopyFromScreen(Int32 sourceX, Int32 sourceY, Int32 destinationX, Int32 destinationY, Size blockRegionSize)

Error:message The handle is invalid

Radim Köhler
  • 122,561
  • 47
  • 239
  • 335
manglerman
  • 13
  • 2

1 Answers1

0

Your program stops because it is not able to take the screen shot (which is what your exception shows).

This is because, when you are on a remote session there is not screen, the screen is in fact the screen where you opened the session from (your screen), so when you close or you minimize the mstsc window your remote session does not have a screen anymore.

Try to handle the exception so your application does not finish completely (try.catch block for instance).

polkduran
  • 2,533
  • 24
  • 34