Forum Discussion

mgy333's avatar
15 years ago

dotNET.System_Windows_Forms.Clipboard.GetDataObject() in TestComplete 7.51

I use dotNET.System_Windows_Forms.Clipboard.GetDataObject() to check if the clipboard has any data on it. The code is similar to: function ClipboardIsAvailable() {         var oDat...
  • Dmitry_Nikolaev's avatar
    15 years ago

    Hi Motoo,

    Let me quote the Clipboard.GetDataObject Method MSDN article:

    The Clipboard class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute.

    So, to avoid the problem, you need to set the Preferred apartment model of the calling thread CLR Bridge option to Single-threaded apartment. See the Project Properties - CLR Bridge Options help topic for details.

    I hope this helps.