I'm writing a console app in C#, using Mono on OS X.
On Windows, here is how I copy text to the clipboard:
Clipboard.SetText("text");
...from a method marked up with the STAThread attribute:
[STAThread] // for OLE
public static void Main (string[] args)
{
Clipboard.SetText("text");
}
Clipboard is defined in System.Windows.Forms. That code compiles and runs both under the official Microsoft .NET runtime on Windows and on the the Mono runtime on OS X.
On Windows, the text gets copied, so it's not an issue of forgetting a reference or a using statement.
Unfortunately, when I run the code under Mono/OS X, the text isn't actually copied to the Clipboard. Something appears quickly on my Dock and then disappears just as quickly, but either way, the text I'm trying to copy doesn't end up on the clipboard.
So: how do I copy text do the clipboard on OS X (and Linux?) using Mono?
If you're interested in seeing the entire project, the code is here: https://github.com/leeohsheeus/boom-sharp.