Hi,
NET Clipboard.Clear() internally calls Win32 API OleSetClipboard() to
clear the clipboard content.
#OleSetClipboard
http://windowssdk.msdn.microsoft.com.../ms686623.aspx
When an application opens the clipboard (either directly or indirectly by
calling the Win32 OpenClipboard function), the clipboard cannot be used by
any other application until it is closed. If the clipboard is currently
open by another application, OleSetClipboard fails.
You can verify this by creating a simple program which opens the clipboard:
if (OpenClipboard(hWnd)) {
::MessageBox(hWnd, _T("Clipboard opened, no other application can
change the content of clipboard."), _T("Message"), 0);
CloseClipboard();
}
When the message box is shown, call Clipboard.Clear() from .NET will fail
with the exception you're experiencing.
From OpenClipboard()'s documentation:
#OpenClipboard
http://windowssdk.msdn.microsoft.com.../ms649048.aspx
You can also see this statement: OpenClipboard fails if another window has
the clipboard open.
So your issue seems some other application is opening the clipboard and
forget to call CloseClipboard() properly.
I hope this helps. Please feel free to post here if anything is unclear.
Sincerely,
Walter Wang (wa****@online.microsoft.com, remove 'online.')
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.