T
Tony
When using Clipboard.SetDataObject (string, true) a COM exception occurs,
"The requested clipboard operation failed. (800401D0)". If the same call is
made again, it works without issue. Note the exception *only* occurs if the
second parameter is set to "true".
This exception only occurs on *some* servers (Win2003) but not all.
Any ideas? .
Here is a sample console application which generates the exception.
C:\temp>CopyToClipBoard.exe true
saveContents = True
Exception caught from 1st copy: The requested clipboard operation failed.
(800401D0)
Attempting second copy. Press ENTER to continue.
All Done!
C:\temp>CopyToClipBoard.exe false
saveContents = False
Attempting second copy. Press ENTER to continue.
All Done!
C:\temp>
[STAThread]
static void Main(string[] args)
{
const string DEFAULT_STR = "Hello everybody!";
bool saveContents = ((args.Length > 0) && (args[0].ToLower () == "true"));
Console.WriteLine ("saveContents = " + saveContents);
try
{
System.Windows.Forms.Clipboard.SetDataObject (DEFAULT_STR + ": Attempt #1",
saveContents);
}
catch (System.Runtime.InteropServices.ExternalException ex)
{
Console.WriteLine ("Exception caught from 1st copy: {0} ({1:X})",
ex.Message, ex.ErrorCode);
}
Console.WriteLine ("Attempting second copy. Press ENTER to continue.");
Console.ReadLine ();
try
{
System.Windows.Forms.Clipboard.SetDataObject (DEFAULT_STR + ": Attempt #2",
saveContents);
}
catch (System.Runtime.InteropServices.ExternalException ex)
{
Console.WriteLine ("Exception caught from 2nd copy: {0} ({1:X})",
ex.Message, ex.ErrorCode);
}
Console.WriteLine ("All Done!");
}
"The requested clipboard operation failed. (800401D0)". If the same call is
made again, it works without issue. Note the exception *only* occurs if the
second parameter is set to "true".
This exception only occurs on *some* servers (Win2003) but not all.
Any ideas? .
Here is a sample console application which generates the exception.
C:\temp>CopyToClipBoard.exe true
saveContents = True
Exception caught from 1st copy: The requested clipboard operation failed.
(800401D0)
Attempting second copy. Press ENTER to continue.
All Done!
C:\temp>CopyToClipBoard.exe false
saveContents = False
Attempting second copy. Press ENTER to continue.
All Done!
C:\temp>
[STAThread]
static void Main(string[] args)
{
const string DEFAULT_STR = "Hello everybody!";
bool saveContents = ((args.Length > 0) && (args[0].ToLower () == "true"));
Console.WriteLine ("saveContents = " + saveContents);
try
{
System.Windows.Forms.Clipboard.SetDataObject (DEFAULT_STR + ": Attempt #1",
saveContents);
}
catch (System.Runtime.InteropServices.ExternalException ex)
{
Console.WriteLine ("Exception caught from 1st copy: {0} ({1:X})",
ex.Message, ex.ErrorCode);
}
Console.WriteLine ("Attempting second copy. Press ENTER to continue.");
Console.ReadLine ();
try
{
System.Windows.Forms.Clipboard.SetDataObject (DEFAULT_STR + ": Attempt #2",
saveContents);
}
catch (System.Runtime.InteropServices.ExternalException ex)
{
Console.WriteLine ("Exception caught from 2nd copy: {0} ({1:X})",
ex.Message, ex.ErrorCode);
}
Console.WriteLine ("All Done!");
}