Clipboard SetData / GetData troubles with VPC and TS
This one of those posts you can categorize is WTF (see me WPF presentation to know what is it) it is not working. However, you, probably will face with the problem now or after.
Symptoms: You are trying to set and get clipboard data from Virtual PC or remote computer by using Terminal Services and nothing happens. When you are using .NET, you’re getting Unhandled exception. If you’ll dig deeper, you’ll find 0x800401D0 (CLIPBRD_E_CANT_OPEN) exception.
Reason: Passing data through TS or VPC pipes bug
Solution: Just retry a couple of times.
Actually, in unmanaged and COM world, you’ll never face this problem, because of the way we are handling OleSetClipboard() and OleGetClipboard() methods (which wrapped by .NET Clipboard.GetData/Clipboard.SetData Set/Get Text etc. methods). So, something like following functions will solve your problems.
public static IDataObject GetRemoteClipboardDataObject()
{
for (int i = 0; i < 10; i++)
{
try
{
return Clipboard.GetDataObject();
}
catch { }
System.Threading.Thread.Sleep(100);
}
}public static void SetRemoteClipboardDataObject(object data)
{
for (int i = 0; i < 10; i++)
{
try
{
Clipboard.SetDataObject(data);
return;
}
catch { }
System.Threading.Thread.Sleep(100);
}
}
Now, to be honest with myself, take a look into one of Clipboard.SetDataObject method signatures in .NET framework 2.0
//Attempts to place data on the system Clipboard the specified number of times and with the specified delay between attempts, optionally leaving the data on the Clipboard after the application exits.public static void SetDataObject ( Object data, bool copy, int retryTimes, int retryDelay )
Don't it looks familiar?Have a nice day and be honest with yourselves.
October 24th, 2007 · Comments (4)
4 Responses to “Clipboard SetData / GetData troubles with VPC and TS”
Leave a Reply
Discover other tags
My tools
- .NET Framework Detector
- Duplicate images finder
- Exchange Security Policy for Windows Mobile Devices Fix
- Gas Price Windows Vista SideBar gadget
- Israel Traffic Information Windows Vista SideBar gadget
- Localization fix for SAP ES Explorer for Visual Studio
- LocTester
- RTL and LTR in Windows Live Writer
- Silverlight controls library
- Snipping tool integration plugin for WLW
- USB FM receiver library
- Vista Battery Saver
- WebCam control for WPF
- Windows Live SkyDrive attachment for Windows Live Writer
- Wireless Migrator
- WPF Virtual Keyboard




January 1st, 2009 at 12:25 am
Hello.
Can anyone utter me how I would get a bother onto my mobby?
The vade-mecum is useless…
January 1st, 2009 at 12:25 am
That is pretty nasty one. Shame we need to use a hack as the solution.
January 1st, 2009 at 12:25 am
Challenge: create visual clipboard watcher, that displays and saves Bitmaps right after they arrives
October 18th, 2011 at 4:57 am
OpenClipboard Failed (Exception from HRESULT: 0x800401D0 (CLIPBRD_E_CANT_OPEN))
Please i need your help about this!